不工作,我不理解为什么这个下面的代码没有进行重定向,我已经破坏了会话,因此病情应该是真实的,但它不是重定向到这个页面,为什么页面重定向在PHP
<?php
session_start();
if(!isset($_SESSION['userid'])) {
header('Location: Login.html');
exit;
}
?>
但在注销php重定向工作正常。
<?php
session_start();
session_destroy();
header('Location: Login.html');
exit;
?>
编辑
我可以看到Chrome开发工具中的重定向呼叫,但它实际上不是重定向
请帮助我理解我的代码中的错误。
在打开'<?php'标记后立即向文件顶部添加错误报告 'error_reporting(E_ALL); ini_set('display_errors',1);'看看它是否产生任何东西。 – 2014-10-02 15:41:40
'isset'不检查值是否为真。它检查密钥是否存在...所以如果$ _SESSION ['userid']'有但是是false,它不会重定向。您应该使用'empty'代替。 – Cfreak 2014-10-02 15:41:43
http://stackoverflow.com/questions/18539403/chrome-cancels-cors-xhr-upon-http-302-redirect,http://code.google.com/p/chromium/issues/detail?id=103458 ,http://serverfault.com/questions/363275/chrome-caching-302-redirects – 2014-10-02 15:49:54