Re: deleting $_SESSION

From: Date: Mon, 11 Apr 2005 17:45:23 +0000
Subject: Re: deleting $_SESSION
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-212814@lists.php.net to get a copy of this message
AndreaD wrote:
I have a session variable called $_SESSION['total'] the problem is I can't delete/reset it. I have tried $_SESSION['total']= 0; $_SESSION['total']= "";
I guess you didn't know/think of trying null: $_SESSION['total'] = null; ...which has the same effect as using: unset($_SESSION['total']); // as you have been told on at least 3 diff occasions ;-) this oneliner might give you a little insight: <?php $x=1;$y=2;unset($x);$y=null;var_dump($x,isset($x),empty($x),$y,isset($y),empty($y)); ?> I encourage you to read the following pages for a better understanding of variables: http://php.net/unset http://php.net/empty http://php.net/isset, and this section: http://php.net/variables have fun! rgds, Jochem PS - personally I try to remember to set a var to null if the code is inside a loop, in order to minimize function call overhead. (anyone with real skill care to comment as to whether there is actually a difference between setting a var to null and calling unset on it? also speedwise?)
and the thing remains. Is there a special way to delete them?? AD


« previous php.general (#212814) next »