0
私はYii2フレームワークのセッションタイムアウトについて疑問に思っていますYii2セッションブラウザが閉じられたときのタイムアウト?
セッションデータは自動的にアンセットされますか?
ブラウザが閉じている場合にこれを設定できますか?
私はYii2フレームワークのセッションタイムアウトについて疑問に思っていますYii2セッションブラウザが閉じられたときのタイムアウト?
セッションデータは自動的にアンセットされますか?
ブラウザが閉じている場合にこれを設定できますか?
セッション変数は、ブラウザが開いているときにのみ機能します。ブラウザを閉じると、ブラウザが終了します。情報を保存したい場合は、Cookieを使用する必要があります。 Yii2ドキュメントから
:
あなたは、次の コード使用して現在のリクエストでCookieを取得することができます。
// get the cookie collection (yii\web\CookieCollection) from the "request" component
$cookies = Yii::$app->request->cookies;
// get the "language" cookie value. If the cookie does not exist, return "en" as the default value.
$language = $cookies->getValue('language', 'en');
// an alternative way of getting the "language" cookie value
if (($cookie = $cookies->get('language')) !== null) {
$language = $cookie->value;
}
// you may also use $cookies like an array
if (isset($cookies['language'])) {
$language = $cookies['language']->value;
}
// check if there is a "language" cookie
if ($cookies->has('language')) ...
if (isset($cookies['language'])) ...
http://www.yiiframework.com/doc-2.0/guide-runtime-sessions-cookies.html#cookies
を