PHP Unset Session Variable
Unset is a function. Therefore you have to submit which variable has to be destroyed.
unset($var);
In your case
unset ($_SESSION["products"]);
If you need to reset whole session variable just call
session_destroy ();
You can unset session variable using:
session_unset
- Frees all session variables (It is equal to using:$_SESSION = array();
for older deprecated code)unset($_SESSION['Products']);
- Unset only Products index in session variable. (Remember: You have to use like a function, not as you used)session_destroy
— Destroys all data registered to a session
To know the difference between using session_unset
and session_destroy
, read this SO answer. That helps.