Home » Php » Unable to unset session on clicking link

Unable to unset session on clicking link

Posted by: admin June 30, 2018 Leave a comment

Questions:

I have set session_start() on every page. Now, I want to unset session

 <div style="text-align: center;">
     <a href="clearorder.php">Clear order</a>
      </div>

Here is my clearorder.php

<?php
session_start(); 
$_SESSION["cart"] = array();
session_destroy(); 
header('location:'.$_SERVER['HTTP_REFERER']);
?>

But the session is not clearing and displaying the data of the session. What could I be missing?

Answers: