I want to do so that the authorization would hold on forever. here is the LoginForm authorization model code

public function login() { if ($this->validate()) { return Yii::$app->user->login($this->getUser(), 0); } return false; } 

I suppose that the second parameter of the duration is just the time of the session, and if correctly understood, then 0 is infinite. in config here such settings

  'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, ], 

However, after some time, the authorization flies. What can be wrong? UPD I don’t close the session anywhere .. But re-opening sessions by code are possible. Maybe this is the case?

    1 answer 1

    Add the authTimeout key to the user authTimeout and remove enableAutoLogin=>false

     'user' => [ 'identityClass' => 'app\models\User', 'authTimeout' => 60 * 60 * 24 * 100, //100 дней для примера ], 

    PS It is important to know that this key will work only if enableAutoLogin=>false .

    Details about authTimeout

    • and what should I prescribe that it would be infinite? - Anatoly
    • Corrected. They could have done it themselves ... - Urmuz Tagizade
    • I suppose that it was in php.ini, there is a session.gc_maxlifetime parameter - Anatoly
    • This answer is considered to be workable in the case when php.ini itself is configured correctly for you, that is, if you have session.gc_maxlifetime = 10 seconds, then whatever you do - the session will be 10 seconds. - Urmuz Tagizade
    • and if you put 0 then it will be considered infinity? - Anatoly