Re: Bug #13229 - some analysing

From: Date: Fri, 14 Sep 2001 11:17:07 +0000
Subject: Re: Bug #13229 - some analysing
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-65925@lists.php.net to get a copy of this message
> Hi f0lks, > > I've just subscribed to this mailing list because I have a problem with > session handling that seems to be a bug (the one described at > http://www.php.net/bugs.php?id=13229). > > I've spend a lot of time on analyzing session handling so I hope my > results help somebody to fix this bug. > > > Before PHP 4.0.6 the problem was, that changes in $HTTP_SESSION_VARS > were not saved if register_globals was enabled. > > In PHP 4.0.6 the problem is, that changes in $HTTP_SESSION_VARS won't > be saved if register_globals is enabled AND when the changed variable > wasn't registered before that script call. > > (Don't tell me I should turn off register_globals when I prefer to use > $HTTP_SESSION_VARS - it's not my server I'm working on.) [snip] I don't think this is a bug, it looks like a misunderstanding of the API. (Perhaps it is my misunderstanding ;-) session_is_registered() seems only to test if you have registered a variable, not if the variable has been retrieved by the session code as of yet. session_register() should be called regardless of whether or not you need to initialize a variable, so what you need to do seems to be this: session_register("foo"); if(!$HTTP_SESSION_VARS["foo"]) // foo uninitialized { $HTTP_SESSION_VARS["foo"]=0; // probably no need to do this, already zero } $HTTP_SESSION_VARS["foo"] += 1;

« previous php.dev (#65925) next »