在FireFox中通过unset_session删除PHP中的会话的问题

时间:2011-09-12 18:24:46

标签: php firefox session exit logout

当我按下退出链接时,它不会从页面退出用户,但是当我点击它后手动刷新它真的会退出。 注销命令是:

$URL = $_GET['url'];
session_unset();
redirect($URL); 

当页面被重定向时,我看到了会话变量,尽管它们被删除了 手动刷新后就可以了。

Chrome和IE中没有任何问题。

1 个答案:

答案 0 :(得分:0)

为了真正记录用户,您还需要取消设置会话ID和用于将会话ID传播到客户端的cookie。

以下是PHP手册中的示例代码:

<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
    $params = session_get_cookie_params();
    setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
session_destroy();