Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Experts,
I have developed
one web application which can contain many users.
I just want to prevent multi ple login in web application in terms of like -
1. If
User1 is logged In, form another browser or another machine the
User1 can
not login untill previous login has been distroyed.
2. If User1
Logged Out from Browser "a" or Machine "a", from another machine or
;
browser User1 can login.
3. If Browser closed with Logout, User1 can login again from same browser or
different
browser or machine.
4. And The most important
point is, Suppose Application, Machine Or b
rowser


close unexpectedly , The into system.

Can u Help me? Thanks in advance.
Posted
Updated 15-May-13 2:49am
v2

You have to implement this by using Session events in Global.asax file and also you need to write some javascript code to check whether the browser has been closed directly without logout.

But doing all these stuff also cannot achieve fully to restrict multiple logins because in some cases in some cases it might fail and user wont be able to login.

There is a good explanation in the below links, I recommend you to go thru them:

http://forums.asp.net/t/1144906.aspx[^]

http://www.dotnetfunda.com/articles/article1083-restricting-user-to-login-multiple-times-using-same-credentials.aspx[^]


Hope it helps!!!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-May-13 11:15am    
5ed.
—SA
Mohammed Hameed 16-May-13 1:36am    
Thanks Sergey :). You're always motivating me.
In order to track user login another way out is handle the Session_Start and Session_End event in Global.asax.

You can get the session id when user successfully logged in, just store the session id in your datastore(associate with username).
Delete the session id when Session_End event fires or user manually logout.

If user try to login with the same username from other machine, verify the session id against database. Hope it helps.

It's more reliable than the MemberShip approach, but not perfect since HTTP is a disconnected, stateless protocol.
 
Share this answer
 
v2
Comments
Mohammed Hameed 15-May-13 9:35am    
Good explanation. +5 for this.

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