首页 > 解决方案 > 单击链接时无法取消设置会话

问题描述

session_start()在每一页上都设置了。现在,我想取消会话

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

这是我的clearorder.php

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

但是会话没有清除和显示会话的数据。我会错过什么?

标签: phpsession-variables

解决方案


我让我的注销按钮工作的方式很简单

"Button that leads to (Example: logout.php)"
<?php
Session_start();
Session_destroy();
Header("Location: "Whatever page you want" ");
?>

推荐阅读