Question

I have 5 Session in my script. I want to destroy two from them.

<?php
  session_start();
  $_SESSION['productid'] = "123";
  $_SESSION['imglink'] = "x.png";
  $_SESSION['oldprize'] = "120";
  $_SESSION['spacialprize'] = "100"
  $_SESSION['productname'] = "AC";
?>
Was it helpful?

Solution

You can use unset() for this as:

unset($_SESSION['productname']);

$_SESSION['productname'] is a variable and unset() destroys any variable placed within it.

OTHER TIPS

This is only a Session Value:

$_SESSION['productname'] = "AC";

If you want to "destroy" this, you can use following function:

unset($_SESSION['productname']);

If you use "session_unset();" and "session_destroy();" your whole session values are destroyed, and you have to restart a session.

unset($_SESSION['productname']); unset($_SESSION['productname']);

"session_destroy():" will destroy the whole session

Use the following


unset($_SESSION['productname']);
 
unset($_SESSION['productname']);

After this, your session will be deleted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top