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

t0berius's avatar

show "logged in" sessions / logout single session

Is there a way to show the user all sessions for his account (current logins)?

Looking for a way to list the current sessions of a user / option to "logout" sessions by the user itself. -Is there some doc available? Until now I wasn't able to find anything related inside the laravel docs itself.

0 likes
4 replies
JohnBraun's avatar

I don't know if there is a way to show all current sessions, but I know that a user can request to log out all of his other devices, is that what you are trying to achieve?

If so, check out this video

And in the Laravel documentation: Logging Out

MisstypingMeerkat's avatar

I think there won't be any straightforward answer to this, because you only "know" when a user logs in, requests a new page, or actively logs out - but not if he puts his computer to sleep, loses connection, closes the browser, walks away etc.

Most sites with a "x users online" counter only count the number of logins/pageviews within the last 30 mins (or whatever your session lifetime is).

If you want to get more accurate, you have to use javascript and send a "alive" ping to your server every few seconds or so. Youtube does this to show people how long a visitor watched a video, or where in the video they left or stopped viewing.

mstrauss's avatar

@jaheller Do you want to show the user a history of their logged in sessions? Like, dates/times that their account has been logged into over say the past x of days? Or do you want to show them that another user is currently logged into the account, kind of like Gmail does?

t0berius's avatar

@johnbraun @mstrauss

I was looking for a way to display all current sessions of the user and provide an option to logout a "single" session.

I've already done some research for logoutOtherDevices. The logic behind this function is easy, it will set a new password and make all other sessions invalid, by invalidating the "old" password (middleware will perform check).

In my current setup I'm using redis to store all sessions, so switching to a SQL based session storage won't be an option. Any ideas how to solve this? Is there any package? Using logoutOtherDevices is not usable for the current feature I'm looking to implement. The logic behind multiple sessions in laravel is currently not designed to "support" my feature in any way.

Please or to participate in this conversation.