Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In ASP.NET application how to ensure one user login in only one machine?

If the user logged in one machine and trying to login in another machine one pop-up should should shown saying that 'Want to logout from other logged in system?'. If yes, other sessions should be killed and allow to login in the current system. How to achieve this? Please guide me.
Posted
Comments
Sergey Alexandrovich Kryukov 1-Mar-13 10:56am    
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

Hi,

As per my understanding you want only one instance of the user login.
1.You can have a column in your login table as IsLoggedin.
2.Update this with a flag like 'Y' to indicate when the user logs in.
3.When user tries to log in from other system,check this flag along with the credentials and if the flag is not 'Y', allow login.
4.Else, display message to logout the active session.


Hope this helps.
 
Share this answer
 
First Create one Dictionary collection in your application startup and add it to Application not Session.

Then Get the Ip Address of users pc:

C#
string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
    ipaddress = Request.ServerVariables["REMOTE_ADDR"];



When User Login Check for the username in your Applications Dictionary Collection. if Username and Ipaddress is same as exists then proceed with Login. if not exists then add that pair and Login. if username exist but ip address is diffrent than present then popup the message that user already logged in other pc.
 
Share this answer
 

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



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