【发布时间】:2009-06-16 17:41:43
【问题描述】:
我一直想知道,如果 PHP 会话在执行脚本的过程中超时,那么 $_SESSION 数组的内容在脚本执行结束之前是否仍然可用?例如:
session_start();
if(! isset($_SESSION['name'])) {
echo 'Name is not set';
exit;
}
// imagine there is a bunch of code here and that the session times out while
// this code is being executed
echo 'Name is ', $_SESSION['name']; // will this line throw an error?
将会话变量复制到本地范围以便稍后在脚本中读取它们而不必继续检查会话超时是否可行?比如:
session_start();
if(isset($_SESSION['name'])) {
$name = $_SESSION['name'];
} else {
echo 'Name is not set';
exit;
}
// bunch of code here
echo 'Name is ', $name;
【问题讨论】:
标签: php session session-timeout