How to disable autologin


Is there a way to prevent autologin user when he leaves my site and then comes back? I thought enableAutoLogin property in User config means that but it doesn’t. Tried to set ajax call to my logout page on window.unload event, but it logs me out when i click something on my sidenav, thought it fires only when the tab is closing.

Maybe the question is stupid, i don’t know much about session and cookies.

I need this because user is providing his passport data (app is based on that) and i don’t want any leaks of it.

Have read many stackoverflow topics and turns out i can’t do that with no hacks.

So i’m thinking about set session expire time at 5-10 sec. every time he leaves the page of my site and then set it back to normal expire time every time he comes back.

Could somebody tell me how to change session expire time from controller?

I’ve found protected renewIdentityCookie method in User source class and tried to do it that way, but


always returns NULL

Still need to know if there is a way to change session lifetime manually from controller.



Yii::$app->session->setCookieParams(['lifetime' => 10])

don’t work