RE: [PHP] Using unset with $_SESSION
| From: | Ford, Mike [LSS] | Date: | Wed, 28 Jan 2004 10:23:35 +0000 |
| Subject: | RE: [PHP] Using unset with $_SESSION | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176025@lists.php.net to get a copy of this message | ||
On 27 January 2004 15:52, trlists@clayst.com wrote:
> I am trying to find a reliable method to clean out all session
> variables and start clean.
>
> Running PHP 4.3.1 on Win2K developing a web app to run on Linux.
> Session cookies are enabled, register globals is off. I access all
> session variables with $_SESSION.
>
> What I have found is that if I use unset($_SESSION), set a single
> variable, and redirect, the OLD session data is passed to the
> new page.
> However if I use session_unset() or $_SESSION = array() and set my
> single variable, the data is passed properly.
>
> Shouldn't unset($_SESSION) work?
No. The following Caution appears in the manual (at http://www.php.net/manual/en/ref.session.php#session.examples):
Caution
Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of
session variables through the $_SESSION superglobal.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211