Z
Z
zolroman2014-05-20 13:59:44
ASP.NET
zolroman, 2014-05-20 13:59:44

How can I prevent multiple users from accessing the site under the same account?

It is necessary that when a user logs in with the same login from another browser / computer, the session of the previous session ends (i.e. There are 2 people working under the same account. Person number 1 is authorized, when person No. 2 is authorized, the session of person No. 1 ends ).
The site is written asp.net mvc 4, FormsAuthentication is used.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
froosty, 2014-05-20
@froosty

Add the "auth_key" field to the database in the users table, in which each time you try to log in, write a random string, which after successful authorization, write in the cookie (well, or how you store authorization data there). And where you check the "authorization" of the user, add another check for the correspondence of auth_key from the table and auth_key from cookies. It turns out that you will constantly store a certain key for the last authorization in the database, and all previous ones will be cut off, because. the cookies will contain the old auth_key. This is in the simplest version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question