标题后PHP会话被破坏/丢失 [英] PHP session destroyed / lost after header
问题描述
我有一个脚本,它在使用 header()
重定向到 /
之前设置了一些会话值。
我已经阅读了很多关于 $ _ SESSION
变量被销毁/ (),甚至在我实现这个之后:
// set session here
session_regenerate_id(true);
session_write_close();
header(Location:/);
session_start()
设置正确地方,有没有人知道我可能会失踪的任何东西?
在index.php页面,我有这个:
在session_start();
print_r($ _ SESSION);
不输出:'(
代码非常复杂为了解决这个问题,我们得出结论认为这是一个问题,服务器配置,考虑到主机是众所周知的这种事情,这并不奇怪。
I've got a script that sets some session values before redirecting to /
using 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()
is set in the correct places, does anyone know of anything that I might be missing?
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会话被破坏/丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!