M
M
MasterCopipaster2021-10-10 23:41:13
symfony
MasterCopipaster, 2021-10-10 23:41:13

Is it possible to somehow limit the number of concurrent sessions per user in Symfony 5?

In the standard Symfony 5 authorization, a user can log in as many times as he wants from different machines (or clients).
Are there any practices on how to limit the number of these sessions? For example, I don't want the user to be able to open more than two sessions. How can this be implemented? (More interested in the correct algorithm than the code).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2021-10-10
@MasterCopipaster

It seems to me that this is not quite a question about symphonies, but nevertheless I will answer.
Store each user session in a database. Store data such as user ID, IP, user agent, time zone, etc. And in the application, check if the user logged in from another device (browser), then tell him to end the last session or this session will be automatically deleted after 5 minutes if the user does not continue this session.
I think this is the simplest solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question