Session timeout in Yii2



PHP Snippet 1:

    'components' => [
       'session' => [
            'class' => 'yii\web\Session',
            'cookieParams' => ['lifetime' => 7 * 24 *60 * 60]
       ],
   ]

PHP Snippet 2:

Yii::$app->session->set('unique_code', 'xxxx');
Yii::$app->session->set('code_time', 'xxxx');

PHP Snippet 3:

'user' => [
        'identityClass' => 'common\models\User',
        'enableAutoLogin' => false,
        'authTimeout' => 3600, // auth expire 
    ],'session' => [
        'class' => 'yii\web\Session',
        'cookieParams' => ['httponly' => true, 'lifetime' => 3600 * 4],
        'timeout' => 3600*4, //session expire
        'useCookies' => true,
    ],

PHP Snippet 4:

CREATE TABLE YiiSession
(
    id CHAR(40) NOT NULL PRIMARY KEY,
    expire INTEGER(11) NOT NULL,
    data BLOB
);

PHP Snippet 5:

'components' => [
    'session' => [
        'timeout' => 1440, //acá colocas el tiempo en segundos
        'class' => 'yii\web\DbSession',
        'sessionTable' => 'YiiSession',
    ],
    'user' => [
        'identityClass' => 'app\models\User',
        'enableAutoLogin' => false,
    ],
],