I just read further on the manual page for session_register. It also
contains the following:
Caution
This registers a global variable. If you want to register a session variable
inside a function, you need to make sure to make it global using global() or
use the session arrays as noted below.
R
Message-
From: Richard Fox [mailto:[EMAIL PROTECTED]]
Sent: 04 March 2002 16:03
To: PHP
Subject: RE: [PHP] Session variable scope - surprise!
Then, when
session_register("");
is called (even on a variable which is going out of scope) what actually
happens? Where is the dat
Then, when
session_register("");
is called (even on a variable which is going out of scope) what actually
happens? Where is the data actually stored? I know it isn't in the file yet
(I have session.save_handler = files) because nothing is written to the file
until the script exits. So the me
DataVisibility Ltd - http://www.datavisibility.com
Tel: 0141 435 3504
Email: [EMAIL PROTECTED]
-Original Message-
From: Richard Fox [mailto:[EMAIL PROTECTED]]
Sent: 04 March 2002 15:26
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Session variable scope - surprise!
OK, but then how do you expla
OK, but then how do you explain:
";
}
global $HTTP_SESSION_VARS;
session_start();
reg();
if (session_is_registered("test")) {
$tt = $HTTP_SESSION_VARS["test"];
echo "session variable test=<$tt>";
}
else
echo "You really don't know what you're doing, do you?";
?>
This still gives me
I think session_register registers the variable and its value as a global.
In this case, $test's global value is nothing. nada. Because it doesn't
exist globally.
In the reg() function, what is being output is a LOCAL variable called
$test. Not a global value.
If you put the line
global
6 matches
Mail list logo