0

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();
}


?>
user3156220
  • 25
  • 1
  • 5

2 Answers2

1

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.

Rikesh
  • 26,156
  • 14
  • 79
  • 87
0

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

Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91