note 17612 deleted from function.session-register by jimw
| From: | jimw@php.net | Date: | Tue, 18 Dec 2001 22:28:49 +0000 |
| Subject: | note 17612 deleted from function.session-register by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23276@lists.php.net to get a copy of this message | ||
Problem: Registering Variables within a function.
With register_globals=off the following code....
function foo()
{
session_start();
$GLOBALS['foovar']=1;
session_register("foovar");
}
still produces...
sess_$PHPSESSID
-----------------------
!foovar|
My Solution
function foo()
{
session_start();
$GLOBALS['foovar']=1;
$GLOBALS["HTTP_SESSION_VARS"]["foovar"]=1;
}
produces
sess_$PHPSESSID
-----------------------
foovar|i:1;
Note: You don't appear to have to use session_register('foovar'). But if you use
session_register without $GLOBALS["HTTP_SESSION_VARS"]["foovar"] it won't
work.