Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to allow only one concurrent login per user in Asp.Net web application?

I am working on one web application in which i want to make sure that website allow only one login per UserID at a time .If the user with same UserId already logged in the aplication should not allow concurrent login.

How to check that current user already logged in or not.Which state management technique I need to use like session,cache or application,DB?

How to reset or remove value in state manegement when:

1.once user loggs out

2.User directly closes browser without log out

3.User nevigates to another site by just changing url

Can you please guide me on the same.

Thanks.
Posted

 
Share this answer
 
Just do one thing. In your database, in your usertable, add one bit field called IsLoggedin. when user login check for true or false value. If value is true(i.e. already logged in), then automatically redirect to home page. and if value is false(not logged in), then update that value to true, and redirect.
Refer this
[^]

You need to use session management in this. Store the username as sessionID variable.
the Abandon method should work like Session.Abandon();
If you want to remove a specific item from the session use something like Session.Remove("YourItem");
And if you are using this Database approach to track User login status, after ending session, set the flag to 0(logged out) again.

Hope it helps :)
 
Share this answer
 
 
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