On Wednesday 25 August 2004 12:27 pm, Shaun wrote:
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> > >> 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


Shaun,

For what its worth, I experienced probs with destroying sessions until I added 
another page. On the page in question, I called the 'logout' function and 
redirected to that page:

[logout.php]
<?php session_start(); ob_start(); session_destroy();
header("location: http://your_site.back_to_page_that_is not_logged in.php");
?>

Note that I used an absolute url -- it seems to make a difference. [Btw, I 
note that you use double quotes for $_SESSION['orderinfo'] -- just wondering 
. . . .

HTh,
Andre

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

Reply via email to