Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

This is Ranjith Reddy.

Am working on C#,Asp.net,SqlServer 2005.

I have created a WebApplication in Asp.Net 3.5

I am Facing Problem with Multiple logins in Asp.net 3.5.

NO USER Should LOGIN with SAME USERNAME.

Please can u Explain me how to do this with Appliations and Sessions TOPIC ??

Thanks.
Posted

Hi Ranjith,
Can you be more clear with your question. What do you mean by no user should login with the same user name. Do you mean how to avoid 2 different users giving the same userid as part of registration?. Or do you mean that after user has successfully logged in, you shouldn't allow any other user (even the user who already logged in) should be able to login again from a different browser or different window.

Your solution implementation all depends on your exact requirement. You need to be more specific in framing your question.

Regards
Rajesh
 
Share this answer
 
Comments
Yatin chauhan 16-Jun-12 2:04am    
Hello Ranjit
Please clarify with some more description about your problem that we can try to solve.
You should store Session records in SQL Database.

Also create a Temporary Table (tblLoggedUsers) inside SQL Database where a bit type value is left when User successfully log in. As soon as he Log Out change the Value in of bit to No. Every time user try to Log in, check in that table if user is already logged in or Not. If he is already logged in, throw an error message like, you are already logged in from another place.

tblLoggedUsers Structure:

id UserID IsLoggedIn
1 100 1 --This user is Logged In, At Login form you check,
2 110 0 -- This user is not logged in. He can login.
 
Share this answer
 
Hi,

In this condition you can go for two solutions:
1) You can maintain the user in application state. Refer these links:
Beginners Introduction to State Management Techniques in ASP.NET[^]
http://docs.oracle.com/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm[^]
These links will give you the basic ideas only. just store the list of online user's and check from that list wether the user is online or not. If the user is already online then avoid show a error message.

2)The second option is to maintain an indicator in database table with 0 and 1. When user is not online make that indicator is 0 and vice versa. and check with that endicator that user is online or not. on click of log out make the indicator 0 and also after session timeout you'll have to make the indicator 0.

This will help you.
All the best.
--AK
 
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