Yii2 Users being logged out after a short period of time while they should still logged in for 30 days.
I’m Using PHP 5.6, AWS Elastic Beanstalk and cache session, i also tried the same code on single EC2 server with DB session and file session but it didn’t solve the issue.
I don’t know if this point is helpful or not, when i log in on Firefox browser then close it and then re-opening the site it’s opened as logged out user, i tried the same case on chrome it’s keeping me as logged in user.
I’ve included the relevant parts of the code:
Config
'components' => [
...
'session' => [
'class' => 'yii\web\CacheSession',
],
'user' => [
'identityClass' => 'app\models\User',
'enableSession' => true,
'autoRenewCookie' => true,
'authTimeout' => 657567576,
],
...
]
Login Action
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
Login From
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), 3600 * 24 * 30);
} else {
return false;
}
}