我找不到解决这个问题的方法。基本上我们使用的是一个虚荣的 url 系统,所以它的 user.domain.com。所有文件都像 user.domain.com/home.php 等一样被访问。当您清除 cookie 时,重定向工作,它会提示他们再次登录。但是当我使用注销时,它仍然可以工作,但是当他们返回登录链接时,(user.domain.com,在用户的登录页面上有一个登录表单)它将无法工作。我得到的错误是
错误信息:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address
in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept
cookies.
所有会员页面的重定向代码:
if(!isset($_SESSION['user_name'])) { header("Location: http://$_SERVER[HTTP_HOST]");}
Note: The $_SERVER[HTTP_HOST] captures the user.domain.com value for redirect.
注销代码:
<?php
session_start();
session_destroy();
header( 'Location: $_SERVER[HTTP_HOST]' ) ;
?>
解决此问题的唯一方法是用户清除其 cookie。
更新:使用 logout.php 后,我转到成员页面 user.domain.com/home.php 之一,而不是重定向到 user.domain.com 进行登录,它给了我重定向错误。这可能是会话的问题还是标题的问题?
我可以增强或添加什么来解决这个问题?我试过谷歌搜索,但没有发现任何特别的东西。我真的需要一些帮助来解决这个问题。谢谢。
这是我在 Safari 中收到的错误消息:
Too many redirects occurred trying to open “http://user.domain.com/home.php”.
This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.