Jump to content

Archived

This topic is now archived and is closed to further replies.

da_beaver

[SOLVED] Losing one session variable, rest are still intact

Recommended Posts

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 page

I have tried session_write_close() before doing the redirect

A print_r of $_SESSION on the first page shows all of the variables intact before the redirect is attempted

There 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 buffer

PHP version 4.3.1, Apache version 2.0.5.2 running on Windows 2000

Surely 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
You can set the topic to solved yourself. Its in the bottom left corner.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.