So I am developing a website like ebay where customer can purchase product, add to basket etc. The problem is that every time I click “Empty Basket”, the session stops/destroys (I use session_destroy to empty the cart) and I have to re-login my account. Is there a way where user stays logged in every time s/he clicks empty basket?
if(isset($_GET["emptybasket"]) && $_GET["emptybasket"]==1)
{
$return_url = base64_decode($_GET["return_url"]); //return url
session_destroy();
header('Location:'.$return_url);
}
I tried deleting session_destroy()
but the basket still has products
2
Answers
Instead of destroying your session you should just unset the cart variable of your session.
Or
Store the items the user has added to their basket in an array, then just unset it when they want to clear their basket.