Anil Konsal
Anil Konsal

Reputation: 151

Session expiring in Yii2 despite user activity

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?

Upvotes: 4

Views: 4229

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133380

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.

Upvotes: 2

Related Questions