会话自动注销为什么?

时间:2014-10-02 09:58:08

标签: php session

我在页面中添加了会话限制超时。然后我将其删除,但是无论何时我访问所述页面,它仍然可以起作用,好像我还没有删除会话限制。这意味着限制仍然有效,但不会退出。

  • 问题

为什么,我没有做过什么?

$idle = xxx; 
$session_life = time() - $_SESSION['timeout_logout'];
if($session_life > $idle)
{ 
    session_destroy(); header("Location: index.php"); 
}
S_SESSION['timeout_logout']=time();

// without the session timeout code:

<?php
//initialize the session
if (!isset($_SESSION)) {
    session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
    $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    $msg = "You have been logout successfully.";
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
    //to fully log out a visitor we need to clear the session varialbles
    $_SESSION['MM_Username'] = NULL;
    $_SESSION['MM_UserGroup'] = NULL;
    $_SESSION['PrevUrl'] = NULL;
    unset($_SESSION['MM_Username']);
    unset($_SESSION['MM_UserGroup']);
    unset($_SESSION['PrevUrl']);

    $logoutGoTo = "index.php";
    if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
    }
}
?>

0 个答案:

没有答案
相关问题