Click to See Complete Forum and Search --> : Help using Session_Destroy
LocalHero
10-29-2005, 09:13 PM
I have an order form that is 5 steps over 5 pages. The info is sessioned so it will appear on the 5th page. That page is submitted to the shoppnig cart which also uses (seperate) sessions. When a user trys to fill out another order form, the previous info shows up again. I have read a little about session_destroy. I guess that is what I would use to stop my 5 pages from keeping the info, but I don't want to remove the info from the cart. The info on the 5th page is submitted by javascript. How to I have it destroy only the 5 page session after it is submitted? Thanks for any help!
NogDog
10-29-2005, 10:07 PM
I'd be inclined to think (without knowing more details) that you might be better off just unset()-ing all the session variables that you do not want to be active any more. If you want them all unset, just do:
foreach($_SESSION as $key => $val)
{
unset($_SESSION[$key]);
}
LocalHero
10-29-2005, 10:28 PM
Hmmm. I hadn't thought of that. Sounds like it would work, but still might be tricky in my situation. I'll work on it for awhile and ask for help if I get stuck. Thanks though!
tbirnseth
10-30-2005, 01:44 AM
You could also handle each transaction as a separate session by using session_id() and setting it to the transaction number. The advantage of this is that someone could go away and come back and resume where they left off.
tony
Daniel T
10-30-2005, 01:05 AM
Alternatively, take the shorter route:session_unset();
LocalHero
10-30-2005, 01:19 AM
I've been getting my pages ready to try the unset idea, but could you (Daniel T and tbirnseth) explain your respective ideas a little more? As I said when exiting the 5th page AND entering the cart I would like to forget the info so I may start a new order. I've never tried anything like this so any help getting started would be much appreciated! :D