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

rajankarthiks's avatar

Authenticated User Session time length.

Is there any way to get the Authenticated User Session time duration in laravel? Please give some examples.

When the user logs out of the application i want to store the session length in database.

0 likes
1 reply
mstnorris's avatar

Have you set up your Sessions Database driver?

If so, you can query the timestamps on the sessions table.

Or (and this is by no means the best way to go about it, but it may point you in the right direction) you could set up your own table and capture the last time the User logged in like so:

Event::listen('auth.login', function($user) {
    $user->last_login = Carbon::now(); // assuming you place a last_login property on your User model

    $user->save();
});

Please or to participate in this conversation.