スクリプトの実行中に 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;