Re: Removing/unsetting session variables.

From: Matt Grimm (mgrimm_at_healthtvchannel.org)
Date: 12/24/03


To: php-general@lists.php.net
Date: Wed, 24 Dec 2003 08:21:35 -0900

PHP manual recommends this, which works for me:

// Unset all of the session variables
$_SESSION = array();
// Destroy the session
session_destroy();

--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: mgrimm@healthtvchannel.org
Web: www.healthtvchannel.org
"Alain Williams" <addw@phcomp.co.uk> wrote in message
news:20031224132224.A3323@dill.eb.uk.com...
> I have several variables that I set in a session - to record that a user
is logged in.
> I want to be able to unset them - when they log out.
>
> $_SESSION['PERMS_USER'] = 'fred';
> Sets the variable quite nicely, I can also change it and the change is
recorded.
> I cannot unset it. I have tried (in various combinations):
>
> unset($_SESSION['PERMS_USER']);
> unset($HTTP_SESSION_VARS['PERMS_USER']);
> session_unregister($SESSION['PERMS_USER']);
> session_unregister($HTTP_SESSION_VARS['PERMS_USER']);
>
> None of which have any effect.
>
> What should I do ?
>
> Thanks
>
> Merry Christmas.
>
> -- 
> Alain Williams
>
> #include <std_disclaimer.h>
>
> FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
> best interests of our children. See http://www.fathers-4-justice.org


Relevant Pages

  • Re: Proper way to unset SOME session variables?
    ... Mechphisto wrote: ... If I print out the session values, ... I can't find any other method except unset(). ... the issue into an oddity and points up that I must be doing something ...
    (comp.lang.php)
  • Re: Proper way to unset SOME session variables?
    ... If I print out the session values, ... I can't find any other method except unset(). ... PHP Version 5.2.6 ... If you are checking the session var with isset() then setting it to '' ...
    (comp.lang.php)
  • Re: cnclose() doesnt actually call TTYs close routines
    ... moused opens /dev/consolectl on startup and leaves it ... the TTY's close routine because /dev/consolectl is used multiple times. ... common), the session will be unset when all users are gone, not when ... session itself is being released. ...
    (freebsd-current)
  • Re: Proper way to unset SOME session variables?
    ... If I print out the session values, ... I can't find any other method except unset(). ... What version of PHP are you using? ... If you are checking the session var with isset() then setting it to '' will return false. ...
    (comp.lang.php)