da_beaver Posted March 14, 2006 Share Posted March 14, 2006 Hi,I am setting session variables on a page then doing a header/location redirect to a second page however I am losing one of my session variables. Not all of them, just one.Here are some details/comments:I am doing a session_start() on ALL of my pages, right at the top of each pageI have tried session_write_close() before doing the redirectA print_r of $_SESSION on the first page shows all of the variables intact before the redirect is attemptedThere is nothing in the code or in an included file that unsets/destroys/overwrites the session variable.The code that sets the variable is not within an output bufferPHP version 4.3.1, Apache version 2.0.5.2 running on Windows 2000Surely this shouldn't happen? If I was losing the entire session that would kind of be understandable but losing ONE variable out of about 10 or 11 is very strange.Has anyone experienced this before or can anyone offer an explanation? Let me know if you need any further details.Thanks for any advice offered. Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 14, 2006 Share Posted March 14, 2006 do you have register_globals turned on? i found that one of my scripts behaved this way when i installed it on a server with register_globals on. what happened was that i had a $_SESSION['user'] variable, and on one page, i also had a plain $user variable. well, needless to say, with register_globals on, it overwrote my session variable anyway. Quote Link to comment Share on other sites More sharing options...
da_beaver Posted March 14, 2006 Author Share Posted March 14, 2006 [!--quoteo(post=354872:date=Mar 14 2006, 01:35 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Mar 14 2006, 01:35 PM) [snapback]354872[/snapback][/div][div class=\'quotemain\'][!--quotec--]do you have register_globals turned on? i found that one of my scripts behaved this way when i installed it on a server with register_globals on. what happened was that i had a $_SESSION['user'] variable, and on one page, i also had a plain $user variable. well, needless to say, with register_globals on, it overwrote my session variable anyway.[/quote]I've just checked the .ini file and register_globals is set to off.Thanks for the advice though, I hadn't thought of checking that. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted June 25, 2007 Share Posted June 25, 2007 I am having the same problem as da_beaver, Is it a problem with the settings in PHP or is there some other cause for this? My version is 4.3.11 and register globals is on. Quote Link to comment Share on other sites More sharing options...
trq Posted June 25, 2007 Share Posted June 25, 2007 [quote]and register globals is on[/quote]Can you switch them off? Otherwise, you'll need to rename your variables. There is a conflict as described by obsidian. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted June 25, 2007 Share Posted June 25, 2007 I just wasn't sure If that had solved his problem. So no I cant swith to off, I dont have access, but changing the variable name worked. Thank you. (So if a moderator can, I think this topic can be set to solved) Quote Link to comment Share on other sites More sharing options...
trq Posted June 25, 2007 Share Posted June 25, 2007 You can set the topic to solved yourself. Its in the bottom left corner. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted June 26, 2007 Share Posted June 26, 2007 No I cant I didnt start it so its not there. Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 Done. Quote Link to comment 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.