Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gauravs456's avatar

I want to log the User Details whose session expires automatically how can I do that thing? my laravel version is 5.4

I want to do minimal changes as possible so can anyone help me in that For Example :: when user logs in i have session session lifeTime 120 ie. 2 hours and in my env Session_Driver is database as there is session table in mysql for maintaing the session and i want if anyone logs out including the automatic session expire when user gone i want to create a logout log in my database for that user

In my Config.php its 'driver' => env('SESSION_DRIVER', 'file');

0 likes
3 replies
Snapey's avatar

So I visit your site and load one page. Then I turn off my computer.

What happens next?

I can tell you, absolutely nothing.

The session is only 'expired' when I visit again after 2 hours. However, the session cleanup may have run before then and removed any stale entries.

So, what exactly are you wanting to record?

gauravs456's avatar

@Snapey whenever the user session expires i want to make a logout log in my db so that i can say hey you have logged out due to session expired so what’s the best way to do that?

Snapey's avatar

@gauravs456 but you won't know that the session expired. You will just know that at some point in the future the session is no longer valid

Please or to participate in this conversation.