0

I am working on Asp.Net MVC 5 Razor application. I am using my own database for authentication and keeping data. Now I have a requirement that user with same credentials cannot log in to different devices. I mean user cannot be logged in from mobile and computer same time. He has to log-out at least from one device before logging in to other device.

I have done research, but in vain because most of them are for Web Forms application and are using membership table.

Any help?

3
  • I am using my own database for authentication and keeping data. You could keep track of logged in users and deny them if they are already logged in. Commented Dec 31, 2014 at 10:18
  • How can I keep track of them. Some time user just close browser and does not logout properly. Commented Dec 31, 2014 at 10:20
  • That's the big problem with this sort of requirements. They're as bad as can be. Commented Dec 31, 2014 at 10:20

1 Answer 1

2

He has to logout atleast from one device before logging in to other device.

Don't do that. When someone clears their browser cache, they lose all relation to their session, so they're not logged in anymore and thus cannot log out. When their IP changes (if you bind a session to an IP), they can't log out either.

Just do this: upon logging in, invalidate all previous sessions for that user.

How to implement this depends entirely on how your custom authentication works, so I can't comment on that.

Sign up to request clarification or add additional context in comments.

2 Comments

I am using cookieAuthentication for that. What columns i need to maintain at database level.
"this depends entirely on how your custom authentication works, so I can't comment on that."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.