It looks like it is working as expected.  You must note two things.

First, session variables are updated to new values only when you explicitly
call session_register or when the script ends.  When you call
session_register, the session variable will have the value that the global
variable had at the time the session_register is called.  In your case the
variable is not set so the session variable is empty.  When the script ends
the session variable is assigned the value held by the global variable when
the script ends.  This is why you get "" when you try to print the session
variables.  They have never been updated.

Second, the HTTP_SESSION_VARS array is read only.  You cannot assign values
to session variables this way.  You can only assign values to session
variables by assigning values to the global variable that has been
registered with the session.  This is why neither the global or session
variable was changed in the first part of your example.


Andrew Forgue <[EMAIL PROTECTED]> wrote in message

Slight Problem:

This piece of code:

session_register("testvar"); $HTTP_SESSION_VARS["testvar"] = "testval";
print "Global: $testvar | Track_var: " . $HTTP_SESSION_VARS["testvar"] .
$testvar = "testglobalassign";
print "Global: $testvar | Track_var: " . $HTTP_SESSION_VARS["testvar"] .

Produces this output:

Global: | Track_var:
Global: testglobalassign | Track_var:


Now, The other HTTP_*_VARS works just fine. I dont know where to go to fix
this. The Php.ini file says:

register_globals: on
and I compiled it with --enable-track-vars (even though it should be on by

PHP version is 4.0.6 with apache 1.3.22

Anyone seen this problem or know how to fix?


PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to