PHP session destroyed / lost after header(标头后PHP会话被破坏/丢失)
问题描述
我有一个脚本,它在使用 header()
重定向到 /
之前设置一些会话值.
I've got a script that sets some session values before redirecting to /
using header()
.
我已经阅读了很多关于 $_SESSION
变量在 header()
之后被破坏/丢失的帖子,即使在我实现了这个之后:
I've read many posts about the $_SESSION
variable being destroyed / lost after header()
, even after I implemented this:
// set session here
session_regenerate_id(true);
session_write_close();
header("Location: /");
session_start()
设置在正确的位置,有人知道我可能缺少什么吗?
session_start()
is set in the correct places, does anyone know of anything that I might be missing?
在 index.php 页面上我有这个:
On the index.php page I have this:
session_start();
print_r($_SESSION);
// outputs nothing :'(
代码非常复杂,所以不会全部发布,只是片段.
The code is pretty complex so will not post it all, just snippets.
推荐答案
为了结束这个问题,我们得出的结论是服务器配置有问题,考虑到主机以这种事情而闻名,这并不奇怪.
In the interest of closing this question, we had concluded it was a problem with the server configuration, not surprising considering the host is well known for this kind of thing.
这篇关于标头后PHP会话被破坏/丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:标头后PHP会话被破坏/丢失
基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01