webUser.php
//create/start session
session_start();
$sessionId = session_id();
$_SESSION["sessionid"] = $sessionId;
Home.php
session_start();
$currentsessionId = session_id();
if(!isset($_SESSION['sessionid'])||($_SESSION['sessionid'] !=$currentsessionId))
{
$message = 'Restricted to access! please login';
header("location: login.php?error=$message");
}
答案 0 :(得分:0)
默认会话到期时间为1440秒(24分钟)
参考:PHP Manual: Session configuration
要在运行时增加生命周期,请使用以下命令:
ini_set(’session.gc_maxlifetime’, 2*60*60); // Change the session timeout value to 2 hours