Click here to Skip to main content
15,507,266 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
browser or machine.
4. And The most important
point is, Suppose Application, Machine Or b

close unexpectedly , The into system.

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

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:[^][^]

Hope it helps!!!
Share this answer
Sergey Alexandrovich Kryukov 15-May-13 11:15am    
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
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