Im planning to use ajax to add product into the cart but the session_destroy is giving a lot of headache here too
session_destroy
Moderator: General Moderators
session_destroy
Quick question though. Im creating a cart using session and there is an option to clear the cart and im using session_destroy to do it. However, customer would need to click clear cart twice for it to work. The first click doesnt clear anything (sessions can still be echoed) the second one does it. How can i just destroy the session after 1 click?
Im planning to use ajax to add product into the cart but the session_destroy is giving a lot of headache here too
Im planning to use ajax to add product into the cart but the session_destroy is giving a lot of headache here too
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: session_destroy
It depends where you are destroying the session. After you "click the button" does your script output session data before destroying the session? This would give the perception that it takes 2 attempts to destroy a session.
Re: session_destroy
nope, im positive the damn thing needs to be clicked twice. The echoing part is the last part.
Re: session_destroy
When you destroy a session, you also need to clear the $_SESSION itself and delete the cookie so a new session id will be created. See the example on php.net: http://us3.php.net/session_destroy
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: session_destroy
Sure enough, thanks for picking up my slack. I forgot you had to unset the session after destroying it. 
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
Re: session_destroy
First time I figured that out I remember commenting in my code // die you ******* session. now. die. never again 
Re: session_destroy
I know! PHP needs a function called session_decimate() because destroy is not strong enough 