|
Posted by Michael Windsor on 11/02/06 15:48
Pedro Graca wrote:
> Michael Windsor wrote:
>> For reasons I don't know, if the PHP version is 5 or greater,
>> register_long_arrays is false and $_SESSION exists, the following
>> statement is executed:
>>
>> $HTTP_SESSION_VARS = $_SESSION;
>
> Probably the script was written for PHP version < (something) when the
> superglobal arrays were not defined.
> Instead of changing the script to use the "new" superglobal arrays, the
> programmer chose to copy the $_SESSION array to the $HTTP_SESSION_VARS
> and keep everything else referencing $HTTP_SESSION_VARS['index'].
>
>> This line is stopping any subsequent changes to the $_SESSION variable
>> from being stored in the session file on the server - changes can be
>> made, but are all lost at the end of the page processing and the value
>> reverts to whatever it was before the script was executed.
>
> Check the very end of the script for a line
>
> $_SESSION = $HTTP_SESSION_VARS;
>
>
Thanks for your help.
What you say makes sense and made me realise what the code was for - I'm
afraid I hadn't quite clicked what the test for "register_long_arrays"
was doing: somehow I saw "register_long_arrays" and read
"register_globals" and therefore hadn't realised that $HTTP_SESSION_VARS
isn't pre-populated on my system (by virtue of using the newer,
recommended php.ini in the distribution, as it turns out).
I can't find a corresponding assignment *to* the $_SESSION array in the
same file or that I can trace in any of the other included files. On the
surface, if this were happening, it would appear to perfectly explain my
problem - I write to $_SESSION and it gets overwritten by the contents
of $HTTP_SESSION_VARS at the end of the script.
But this can't be the whole story: I've written code after the last
include that shows the same probem and, in fact, if I remove all the
phpbb code and *just* put "$HTTP_SESSION_VARS = $_SESSION" after
session_start(), it stops $_SESSION behaving properly in exactly the
same way. It doesn't have to be $HTTP_SESSION_VARS, incidentally,
assigning the value of $_SESSION to any other variable has the same effect.
Could this be a bug in PHP?
Thanks again,
Mike
Navigation:
[Reply to this message]
|