note 36943 added to function.unset
| From: | PHP at rn2 dot php dot net | Date: | Tue, 28 Oct 2003 09:49:04 +0000 |
| Subject: | note 36943 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59413@lists.php.net to get a copy of this message | ||
This is for anyone else going mad over unsetting session variables.
I was going insane using the following code:
$varsToUnset = array('foo1','foo2','foo3')
foreach($varsToUnset as $var)
{
if(isset($_SESSION[$var]))
{
$_SESSION[$var] = null;
unset($_SESSION[$var]);
}
}
My session variables were still there! Surely a PHP bug?
In fact getting rid of the unset($_SESSION[$var]) has now sorted this out.
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36943
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36943&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36943&report=yes
Search -- http://master.php.net/manage/user-notes.php