lpeek Posted May 1, 2007 Share Posted May 1, 2007 Hi im setting up a very user-interactive website at www.live-guilds.com i'd like to think im pretty advanced with php and mysql but there is one problem i just cant get my head around and its bugging me... ok so ive set up session variables when a user logs in... used the usual code for it: session_register('username'); $_SESSION['username'] = $username; so now my session variable for 'username' is whats set in $username, which was obviously... yep you guessed it... the persons username... BUT, it all seems to work fine... i have a snippet of code that goes something like this: if ( empty ($_SESSION['username'])) { } else { } its on every page, and if the session var is set then it does one thing, if not it does another... on the login page it works fine, it sets the session variable then it uses the first part of the code... lets say the first part shows a link to logout, and the 'else' shows the code to login. so on the login page, after ive logged in, it shows me the logout page, as it should.. but as soon as i navigate away from this page, lets say, we go back home, or go to the sitemap page, the login code runs... not the logout code... even though its exactly the same code for it on every page, as its called using an 'include' function... Its as if the session variables want to delete themselves every time the page navigates away no matter what i do. Please, any help would be greatly appreciated. feel free to register an account and try login yourself to see the problem with your own eyes. Thanks Link to comment https://forums.phpfreaks.com/topic/49520-problems-using-session-variables/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.