重定向后 PHP 会话变量丢失 [英] PHP session variables lost after redirect
本文介绍了重定向后 PHP 会话变量丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用以下代码重定向后会话变量丢失:
Session variables are lost after using the following code to redirect:
header('Location: ./protected_page.php');
exit; //doesn't seem to do anything
在受保护的页面上,我确保在引用任何会话变量之前使用 session_start().
On protected page I make sure to use session_start() before referencing any session variables.
请帮忙!
推荐答案
您重定向到同一个域.如果您从www.thedomain.com 到 thedomain.com 可能会结束您的会话
You redirect to the same domain.If you are redirecting from www.thedomain.com to thedomain.com can possibly end you session
确保 register_globals 已关闭,您可以在 php.ini 文件中检查这一点,也可以使用 phpinfo().
Ensure register_globals is off, you can check this on the php.ini file and also using phpinfo().
会话变量不会被覆盖.
这篇关于重定向后 PHP 会话变量丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文