我有一个会话
$_SESSION['uid'];
30分钟后是否有一个简单的脚本来结束此会话?非常感谢任何帮助。
答案 0 :(得分:4)
// Inialize session
session_start('admin');
// set timeout period in seconds
$inactive = 30;
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['admin'])) {
$session_life = time() - $_SESSION['admin'];
// Jump to secured page
header('Location: securedpage.php');
if($session_life > $inactive) {
session_destroy();
// Jump to Logout page
header("Location: logout.php");
}
}
$_SESSION['timeout'] = time();