Re: why manual says 'don't use session_register'?
| From: | Erwin | Date: | Tue, 24 Sep 2002 08:54:46 +0000 |
| Subject: | Re: why manual says 'don't use session_register'? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117390@lists.php.net to get a copy of this message | ||
Giancarlo Pinerolo wrote:
> The manual has many cautions that say 'do not use session_regiister,,
> session_is_registered, session_unregister, when the ini setting is
> register_globals=off.
>
> But they still do work, it seems.
> Or how exactly do these function work differently than with
> reg_globals On?
> Can I still continue to use them with reg_globals=off, as they seem to
> work anyway?
If you have register_globals set to off, the $_SESSION array is defined.
The functions session_is_registered, session_unregister and session_register
use the session file, not the $_SESSION array. That means that the function
session_unregister or session_register affects the session file, but not the
$_SESSION array!
That can lead to unwanted results if you check that value later on (in the
same php file). If you use unset($_SESSION['key']) instead of
session_unregister('key'), the value will be removed from the $_SESSION
array AND from the session file.
I recommend following the manual and don't use the session_unregister,
session_is_registered and session_register functions anymore.
HTH
Erwin