phpsessiondestroy

Destroy one session from multiple sessions in php


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";
?>

Solution

  • You can use unset() for this as:

    unset($_SESSION['productname']);
    

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