> -----Original Message-----
> From: Niklas Neumann [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 04, 2001 3:20 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Session variables and register_global
>
> session_register("test");
> $GLOBALS['HTTP_SESSION_VARS']['test'] = 'Hello World!';
>
> does not work properly (session variable test is not
> initialized with the
> value 'Hello World!') if register_globals is turned on, but
> when it is
> turned off?
$test and $GLOBALS['HTTP_SESSION_VARS']['test'] are *not* the same variable
*while on the current page*:
$test = "Goodbye cruel world!";
session_register("test");
$GLOBALS['HTTP_SESSION_VARS']['test'] = 'Hello World!';
echo $test; // prints Goodbye cruel world!
echo $GLOBALS['HTTP_SESSION_VARS']['test']; // prints Hello World!
What happens on the *next page* depends on whether register_globals is on or
off. If it is on, then:
echo $test; // prints Goodbye cruel world!
echo $GLOBALS['HTTP_SESSION_VARS']['test']; // also prints Goodbye cruel
world!
The value in the GLOBAL variable $test gets written to
$GLOBALS['HTTP_SESSION_VARS']['test'] when PHP stores the session variables
between pages.
If register_globals is off, then:
echo $test; // prints nothing
echo $GLOBALS['HTTP_SESSION_VARS']['test']; // prints Hello World!
This is because there are no session variables outside of $HTTP_SESSION_VARS
when register_globals is off. Also, all references to POST/GET variables
must be made through the corresponding $HTTP_***_VARS arrays.
This is a complicated aspect of PHP, and the manual is not real clear on how
this all works. I strongly urge you to write up some short test code and see
for yourself what is going on with register_globals.
Kirk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]