the_oliver Posted July 31, 2007 Share Posted July 31, 2007 Hello, If i store a variable in the session eg: $_SESSION['something'] it is lost between page changes. Is this normal? Is there a way round this? Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/ Share on other sites More sharing options...
phpknight Posted July 31, 2007 Share Posted July 31, 2007 Did you start the session on the other page with session_start()? Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312336 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Share Posted July 31, 2007 show us the line of code where the session is made in the first place (eg. Where you log on??) and then show us a line of code from a page where it is being carried to Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312339 Share on other sites More sharing options...
the_oliver Posted July 31, 2007 Author Share Posted July 31, 2007 session_start() is started very first thing when the user loggs in. On a later page to enter a value: $_SESSION['tid'] = $_POST['tid']; To retreave it: echo $_SESSION['tid']; It works first time. However if a user then submits the form, it is send else where, and when it is sent back having failed that validation, there is no longer a value in $_SESSION['tid']; Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312344 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Share Posted July 31, 2007 is session_start() on every page? it has to be on them all Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312347 Share on other sites More sharing options...
the_oliver Posted July 31, 2007 Author Share Posted July 31, 2007 yes. It is at the top of a page which is included in every file. Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312356 Share on other sites More sharing options...
the_oliver Posted July 31, 2007 Author Share Posted July 31, 2007 It is lost when the redirect is done. (through header("Location: edit.php"); ). Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312360 Share on other sites More sharing options...
calabiyau Posted July 31, 2007 Share Posted July 31, 2007 Hard to say without seeing the rest of your code, but you are making the session variable equal to a post variable on one page, perhaps on the redirect, since there is no post data, the session variable is being set to an empty value. Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312363 Share on other sites More sharing options...
the_oliver Posted July 31, 2007 Author Share Posted July 31, 2007 Hit it on the nail!! A stuppid error! Many Thanks.... Quote Link to comment https://forums.phpfreaks.com/topic/62752-_session-data-lost/#findComment-312368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.