note 31159 added to function.unset
| From: | oliviergeorg at ya dot com | Date: | Fri, 11 Apr 2003 13:01:37 +0000 |
| Subject: | note 31159 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46500@lists.php.net to get a copy of this message | ||
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
--
http://www.php.net/manual/en/function.unset.php
http://master.php.net/manage/user-notes.php?action=edit+31159
http://master.php.net/manage/user-notes.php?action=delete+31159
http://master.php.net/manage/user-notes.php?action=reject+31159