Hello, when user login function
Yii::$app->user->login($user,$duration); It is deleted after closing the browser. How can I save the user in cookies so that I can restore it after opening the browser

  • The documentation says that it is this code that sets the storage both in the session and in the cookies. The second parameter is just for this. Describe the situation in more detail and more code is also desirable. - StalkAlex

1 answer 1

Yii::$app->user->login($this->getUser(), 3600 * 24 * 30);

If you have a standard login form from the advanced application (or similar, where the model has the rememberMe property), I recommend this:

Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);

  • Perhaps you have some kind of incorrect config. Attach it to the question (all config) - newbie67