For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > December 2004 > Session problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Session problem
Andy Jacobs

2004-12-23, 8:56 pm

Hi all

I've written a simple little shopping cart that works fine apart from
one thing. When I come back from Worldpay to my thanks page, I want to
be able to kill the session. At the moment, if you press back enough
times you get back to the cart and it still shows you as having what you
bought previously. I've tried using session_destroy() but it doesn't
work. The session is just started with session_start() - nothing more
fancy than that.

Am I missing something here?

Andy
doug861@comcast.net

2004-12-24, 4:00 am

Andy Jacobs wrote:
> Hi all
>
> I've written a simple little shopping cart that works fine apart from
> one thing. When I come back from Worldpay to my thanks page, I want to
> be able to kill the session. At the moment, if you press back enough
> times you get back to the cart and it still shows you as having what you
> bought previously. I've tried using session_destroy() but it doesn't
> work. The session is just started with session_start() - nothing more
> fancy than that.
>
> Am I missing something here?
>
> Andy



Try ending the session in this manner, destroying the appropriate
cookies, if any:

@session_unset();
$_SESSION = array();
@session_destroy();
@setcookie('user_cart', $user_cart, time() - 60*60*24*30);
$_COOKIE = '';
$PHPSESSID = '';
Jan Pieter Kunst

2004-12-24, 8:58 am

(apologies if this message is a duplicate -- news server problems, it seems)

Andy Jacobs wrote:
> Hi all
>
> I've written a simple little shopping cart that works fine apart from
> one thing. When I come back from Worldpay to my thanks page, I want to
> be able to kill the session. At the moment, if you press back enough
> times you get back to the cart and it still shows you as having what you
> bought previously. I've tried using session_destroy() but it doesn't
> work. The session is just started with session_start() - nothing more
> fancy than that.
>
> Am I missing something here?
>
> Andy


I have successfully destroyed sessions like this:

$_SESSION = array();
session_destroy();
unset($_COOKIE[session_name()]);

JP

--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.

Jan Pieter Kunst

2004-12-24, 8:58 am

Andy Jacobs wrote:
> Hi all
>
> I've written a simple little shopping cart that works fine apart from
> one thing. When I come back from Worldpay to my thanks page, I want to
> be able to kill the session. At the moment, if you press back enough
> times you get back to the cart and it still shows you as having what you
> bought previously. I've tried using session_destroy() but it doesn't
> work. The session is just started with session_start() - nothing more
> fancy than that.
>
> Am I missing something here?
>
> Andy


I have successfully destroyed sessions like this:

$_SESSION = array();
session_destroy();
unset($_COOKIE[session_name()]);

JP

--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Andy Jacobs

2004-12-24, 8:55 pm

In article <BiLyd.624069$D%.234204@attbi_s51>, doug861@comcast.net
wrote:

> Andy Jacobs wrote:
>
>
> Try ending the session in this manner, destroying the appropriate
> cookies, if any:
>
> @session_unset();
> $_SESSION = array();
> @session_destroy();
> @setcookie('user_cart', $user_cart, time() - 60*60*24*30);
> $_COOKIE = '';
> $PHPSESSID = '';


Now I'm sure I'm missing something. I go to one page and display the
session id and get a great big long number. I put the code above in a
file called gone.php and go to that page. i then go back to the page
that displays my session id and refresh it. I've still got the exact
same number.

Maybe I'm not expecting the right thing?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com