PHP - ini_set('session.gc_maxlifetime', 5) - 为什么它不结束会话?
2022-08-30 21:38:06
PHP 脚本如下所示:
<?php // continue.php
ini_set('session.gc_maxlifetime', 5);
session_start();
echo ini_get('session.gc_maxlifetime');
// wait for 7 seconds
usleep(7000000);
if (isset($_SESSION['username']))
{
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$forename = $_SESSION['forename'];
$surname = $_SESSION['surname'];
echo "Welcome back $forename.<br />
Your full name is $forename $surname.<br />
Your username is '$username'
and your password is '$password'.";
}
else echo "Please <a href=authenticate2.php>click here</a> to log in.";
?>
根据超时(即 5 秒),脚本不应打印任何内容。但是,我仍然收到以下消息
5Welcome back Bill. Your full name is Bill Smith. Your username is 'bsmith' and your password is 'mysecret'.
似乎ini_set行('session.gc_maxlifetime',5)不能正常工作。我正在使用windowsXP + XAMMP。
你能告诉我如何让它工作吗?
谢谢