lundi 7 février 2022

How to flush session on Laravel Cartalyst/Sentinel 2 automatic logout

Background

We have a Laravel Application built using Laravel 5.2 and cartalyst/sentinel version 2. When the user is logging in, we're setting some custom session values for our application need, for example:

Session::set('office_name', $officeName);

And in our logout method, we're flushing the session as well:

Sentinel::logout(null, true);
Session::flush();
Session::regenerate();

So, when the user deliberately logs themselves out, the session is working just fine.

Issue

But the issue is: when the Sentinel is automatically logging itself out after a certain (defined?) idle time, it's not flushing the custom sessions. So the user interface is announcing that the user is logged out, and they have to log in again. But we can still see the set session office_name is present there. And there are many other session values that are still present after the automatic logout.

How can we tell the Sentinel to flush the session when itself is automatically logging out?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire