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

Julien44's avatar

Allow one session by user API/SPA

Hello, How can I prevent my users to log with same credentials on multiple devices ? I am developping an API with laravel and a SPA with vuejs

I was using JWT before I know that feature of the application I am working on, so I did an ugly fix temporarily :

Each time an user log in, I store the last jwt generated in my database, and I created a middleware for checking on every request if the jwt used is the last generated.

I know this is a really ugly fix but this was the only thing I tought for preventing users to log on multiple device. Do you have some ideas for implementing this feature ? Will I need to change the auth method from JWT to another thing ? Thanks you

0 likes
0 replies

Please or to participate in this conversation.