note 31159 deleted from function.unset by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 02:28:28 +0000 |
| Subject: | note 31159 deleted from function.unset by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58484@lists.php.net to get a copy of this message | ||
Note Submitter: oliviergeorg@ya.com
----
unset and session variables
====================
I had the same problem as till dot krullmann at gmx dot net.
I think it has to do with register_globals=ON, and that the reason is as follows:
1st page: set the session variable
<?
session_start();
$_SESSION['X'] = 1;
?>
2nd page: unset the session variable
<?
// both $_SESSION['X'] _and_ $X are set
unset($_SESSION['X']);
// $X is still set !!! and will save it the session !!!
?>
3rd page: check the session variable
<?
// since register_globals==ON, PHP has filled again $_SESSION['X']
echo isset($_SESSION['X']);
?>
and we see it is set !!!
So there are 3 solutions:
a) turn register_globals OFF
b) when unsetting $_SESSION['X'], unset $X as well
c) call session_unregister !
Olivier