Re: Using unset with $_SESSION
| From: | trlists at clayst dot com | Date: | Tue, 27 Jan 2004 16:19:44 +0000 |
| Subject: | Re: Using unset with $_SESSION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-175939@lists.php.net to get a copy of this message | ||
On 27 Jan 2004 Stuart wrote:
> In that case, try this...
>
> foreach (array_keys($_SESSION) as $key)
> unset($_SESSION[$key]);
Yes, I had tried that but forgot to mention it. It does work.
However, I'm still mystified as to why unset($_SESSION) not only
doesn't remove old data from the sesison file when the script exits,
but prevents the new variable I create after that from being saved.
Perhaps $_SESSION as created by PHP is special and is tied to the
session storage, whereas if it is destroyed with unset and then
recreated that link is lost. That would explain the behavior.
----------
Tom Rawson