php - 单击链接时无法取消设置会话
问题描述
我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']);
?>
但是会话没有清除和显示会话的数据。我会错过什么?
解决方案
我让我的注销按钮工作的方式很简单
"Button that leads to (Example: logout.php)"
<?php
Session_start();
Session_destroy();
Header("Location: "Whatever page you want" ");
?>
推荐阅读
- kubernetes - kubernetes 在 pod 中使用具有 root 用户的 nfs 持久卷
- docker - 是否可以在容器内获得指定的 docker ram 限制?
- python - tensorflow - tf.data.Dataset 在批处理之前随机跳过样本以获得不同的批次
- confluence - 使用变量并在内容中显示
- java - 带有背景加载的imageview中的Javafx中心图像
- javascript - 如何在网站上的 github 上获取最新提交
- azure - 推荐实践如何在 Azure Function local.settings.json 文件中包含更复杂的配置 JSON 数据?
- unity3d - Vuforia 无法识别我显示的图像。Unity 3D 2018 最新版本
- python - 用字符串python中的正则表达式替换正则表达式
- reactjs - ReactJS:如果我单击浏览器,则读取未定义的属性“地图”