I am sure I’m doing something wrong, but I’m not clear what.
I have an issue that if a user walks away from their computer for a few hours, that their session data is lost. In config/main.php, I have this:
$config['components']['user'] = [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true], ]; $config['components']['session'] = [ 'name' => 'frontend', 'timeout' => 30 * 24 * 3600, // 30 days ];
If I show this in debug output in a view (Yii::$app->session->timeout), it does indeed say 30 days.
Yet, if I leave my computer for several hours and come back, everything breaks and the user has to restart a session. Basically, a piece of app code breaks:
$model->requestBy = Yii::$app->session->get('requestBy');
This works… until it doesn’t and the session is no longer valid. I am using the php file method currently to debug this. What I find is that the session files in /var/lib/php/sessions go away and when the user creates a new session a new session file appears.
So I’m totally confused. What does Yii::$app->session->timeout do? And what do I need to do so that a session lasts for 30 days? Or even until they close their web browser (because currently they just have to walk away for several hours, even with the web browser and app page open)?