user3156220
user3156220

Reputation: 25

using session_destroy to deleting things in cart

I am doing a e-commerce website. I would like to clarify something.

Let say, If I want to do a session_destroy to the session item that I've in my cart after I click on logout, can I check with you, is it something like this?

<?php

$logout = "login.php";

if(isset($logout))
{
     session_destroy();
}


?>

Upvotes: 0

Views: 156

Answers (2)

Rikesh
Rikesh

Reputation: 26451

session_destroy() destroys all of the data associated with the current session. If you fine with it, you can use or rather use unset to clear any specific session with specifying it's key like: unset($_SESSION['cart_items']);

Reference.

Upvotes: 1

Victor Bocharsky
Victor Bocharsky

Reputation: 12306

In your example isset($logout) always return TRUE and you destroy session every execution of script. Is it that you want?

Upvotes: 0

Related Questions