Session expiring in Yii2 despite user activity

末鹿安然 提交于 2019-12-10 17:06:42

问题


I have started using Yii2 and need to store more information about user in identity. I already know that in Yii2, this should be done using sessions like

Yii::$app->session->set('user.company_id', '121');

This works fine as I am able to get these values later in project using:

Yii::$app->session->get('user.company_id');

. However, these session values are getting wiped up despite user activity on same pages. So after 5-10 minutes, the same user sees some fields based on session value, however, after 1 minute if I refresh the session values go away which should actually happen on session close or user logout.

Any suggestions what I am doing wrong?


回答1:


First check your app\config\main.php or main-local.php if it contains:

'user' => [
    ...
    'enableAutoLogin' => true,
    ...
],

Second check if you have a proper assignment to the value assigned to the variable:

$authTimeout;
$absoluteAuthTimeout;

See here for more.



来源:https://stackoverflow.com/questions/29729026/session-expiring-in-yii2-despite-user-activity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!