Re: deleting $_SESSION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux