Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have to create a website which should not have multiple login for same user not allowed.
I mean, say suppose my website is logged in from Machine A, when I try to login from Machine B, the website should logout from Machine A.
When I again try to login in Machine A, the application should trigger a logout at Machine B.

any help me for this implementation is appreciable.
Thank you
Posted
Comments
ZurdoDev 15-Jan-15 8:50am    
This is a bad idea, but I understand it may be necessary. All you need to do is track this in your db. There is no built-in functionality for this. You'll have to design and build it yourself.

What I have done in the past is to issue (and store in the database) a "token" (guid) when a user logs in and that token must be provided for all subsequent access.
In your scenario, when the user logs in from machine B, a new token will be generated and the one that the process on machine A holds will no longer be valid so access from that machine will fail until a new login is performed from there.

I'm really surprised that this is not a common technique.
 
Share this answer
 
Comments
DamithSL 15-Jan-15 10:30am    
interesting, can you please add more details on how you handle/keep token in client side and how you handle when user connect from different browsers from same PC
Philippe Mori 15-Jan-15 12:20pm    
Other browsers would be handled the same as distinct PC. How to keep the token is not much different that how the system remember that a user is logged on.
Please try this link : Preventing a User From Having Multiple Concurrent Sessions

A common question asked regarding ASP.NET is how can you prevent a user logging on more than once at the same time. Unfortunately, the nature of ASP.NET means that you cannot tell if a user is logged in already. Sure you can log the fact a user has accessed your application, but there is no way to tell that they have abandoned their old session, perhaps by closing their browser, and that their new login is therefore valid.

The link contains a class SingleSessionPreparation which helps you keep track of GUID.
 
Share this answer
 
Comments
sagar wasule 16-Jan-15 0:39am    
any idea how can signout get triggered if the user get logged in from different machine
[no name] 16-Jan-15 0:44am    
Sagar - I would say, you have to define a custom HTTP Module which monitor usage of session GUID as mentioned in above link and implement your logic

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900