注销后重定向

时间:2012-11-17 01:07:36

标签: php redirect

我在登出时遇到将用户重定向到首页的问题。我有一个switch case语句,一个处理注销如下:

    case 'logout':
    offline($_SESSION['user_id']);
    session_destroy();
    include_once 'index.php';
    break;

我认为包括index.php会将用户重定向到首页,因为那是会话时应该发生的事情。但页面只是空白,网址是localhost / web //?a = logout。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

好的,OP!我已经更新了我的答案,即使你没有要求它。所以,再次检查一下

header('Location: http://site.com/index.php');

让你的代码像这样:

case 'logout':
    offline($_SESSION['user_id']);
    session_destroy();
  header('Location: http://site.com/index.php');
   exit();
    break;
相关问题