obay Posted July 23, 2009 Share Posted July 23, 2009 i have a very weird problem.. page1.php: session_start(); $_SESSION[username] = "myname"; header("location:page2.php"); page2.php: print_r($_SESSION); session_start(); print_r($_SESSION); yields: Array( ) Array( ) when the second print_r() is supposed to print the session variable. What is wrong? Any help appreciated!!! Link to comment https://forums.phpfreaks.com/topic/167109-_session-variable-disappears/ Share on other sites More sharing options...
Bendude14 Posted July 23, 2009 Share Posted July 23, 2009 I presume globals are switched off, try echo $_SESSION['username']; Link to comment https://forums.phpfreaks.com/topic/167109-_session-variable-disappears/#findComment-881110 Share on other sites More sharing options...
obay Posted July 23, 2009 Author Share Posted July 23, 2009 thanks for the reply! but what do you mean by globals is turned off? should i turn it on? how? $_SESSION['username'] doesn't work also.. Link to comment https://forums.phpfreaks.com/topic/167109-_session-variable-disappears/#findComment-881113 Share on other sites More sharing options...
haku Posted July 23, 2009 Share Posted July 23, 2009 This doesn't have anything to do with globals - that's a different situation. Change this: $_SESSION[username] = "myname"; to this: $_SESSION["username"] = "myname"; And see if that helps. Link to comment https://forums.phpfreaks.com/topic/167109-_session-variable-disappears/#findComment-881117 Share on other sites More sharing options...
obay Posted July 23, 2009 Author Share Posted July 23, 2009 $_SESSION["username"] = "myname"; doesn't work also.. Link to comment https://forums.phpfreaks.com/topic/167109-_session-variable-disappears/#findComment-881121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.