Re: Destroying a Session
| From: | Shaun | Date: | Wed, 25 Aug 2004 16:27:06 +0000 |
| Subject: | Re: Destroying a Session | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194692@lists.php.net to get a copy of this message | ||
<john@johnallsopp.co.uk> wrote in message
news:50140.82.195.101.197.1093435673.squirrel@www.johnallsopp.co.uk...
> >> function clear_orderinfo() {
> >> global $_SESSION;
> >> unset($_SESSION["orderinfo"]);
> >> }
> >>
> >> However this function doesnt seem to work and the session remains
> >> active, is
> >> there another way to clear a session?
>
> I'm not triffically experienced, but I do have notes on the subject.
> You're wanting to clear the whole session, right?
>
> $_SESSION=array();
> session_destroy();
>
> For specific variables, try assigning FALSE to it
> ($_SESSION['name']=FALSE; or 'unset' works for versions >=4.2.2.
> Otherwise
> use session_unregister. For me under 4.1.2 I had to set to null.
>
> HTH
> J
>
>
Hi,
Thank you for your replies. I am using version 4.3.3 yet unset() doesn't
seem to work. To test this I have placed this line of code in my footer.php
file that appears at the bottom of every page:
echo 'load_orderinfo() = '.load_orderinfo();
Here is the load_orderinfo() function:
function load_orderinfo() {
global $_SESSION;
if (empty($_SESSION["orderinfo"])) {
return false;
} else {
return $_SESSION["orderinfo"];
}
}
Before the $_SESSION["orderinfo"] is created the output in the footer reads:
load_orderinfo() =
When it has been created it reads:
load_orderinfo() = Object;
On the complete_order.php page where I call the clear_orderinfo() function
it goes back to:
load_orderinfo() =
but it on any subsequent page the output returns to:
load_orderinfo() = Object;
But after calling the clear_orderinfo() function surely the
$_SESSION["orderinfo"] should have been destroyed. I hope this makes sense!
Thanks for your help