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

willian123's avatar

"How to Automatically Logout Old Sessions When Limiting to Two Active Sessions in Laravel 11.x (Jetstream 5.x)?"

I'm using Laravel 11.x with Jetstream 5.x, and I want to implement a feature where users are limited to a maximum of two active login sessions. If a user logs in on a third device or browser, the oldest session should automatically be logged out. Any advice, examples, or best practices would be greatly appreciated!

0 likes
1 reply
hyouhoan's avatar

I would using cache in auth middleware to saving session ID by user ID and with timestamp, if the number of session is greater than 2 then just logout the older session

Please or to participate in this conversation.