2013-05-15 168 views
0

30分鐘後,用戶應該得到註銷,但它似乎緩存保持用戶在線的一對夫婦頁/點擊...非緩存頁面

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) { 
    session_destroy(); 
    session_unset(); 
} 

$_SESSION['LAST_ACTIVITY'] = time(); 

// regenerates the session ID periodically to avoid attacks on sessions 
if (!isset($_SESSION['CREATED'])) { 
    $_SESSION['CREATED'] = time(); 
} else if (time() - $_SESSION['CREATED'] > 1800) { 
    session_regenerate_id(true); 
    $_SESSION['CREATED'] = time(); 
} 

$ts = gmdate("D, d M Y H:i:s") . " GMT"; 
header("Expires: $ts"); 
header("Last-Modified: $ts"); 
header("Pragma: no-cache"); 
header("Cache-Control: no-cache, must-revalidate"); 

回答

1
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) { 
    session_destroy(); 
    session_unset(); 
} 

這部分似乎有一個拼寫錯誤,其中1800後的括號之一應該在「大於」符號前面:

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY']) > 1800) { 
    session_destroy(); 
    session_unset(); 
} 
+0

這解決了問題! – user1725969

+0

太棒了:)請在此情況下將此標記爲已接受的答案;) –