Tim*_*Tim 3 php session session-timeout
我一直想知道,如果一个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?
Run Code Online (Sandbox Code Playgroud)
将会话变量复制到本地作用域是否切实可行,以便稍后在脚本中读取它们而不必继续检查会话超时?就像是:
session_start();
if(isset($_SESSION['name'])) {
$name = $_SESSION['name'];
} else {
echo 'Name is not set';
exit;
}
// bunch of code here
echo 'Name is ', $name;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1614 次 |
| 最近记录: |