Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Friends,

How we will know if a user is already logged in to his account from some other place?

Thanks
Posted
Comments
Richard MacCutchan 20-Sep-15 3:27am    
You probably need to guess since you have not provided any context to your question. However, any half decent developer would store that information in the database connected to his/her application.
girishmeena 20-Sep-15 13:46pm    
Thanks for your valuable suggestion !

In practice, you probably can't: all you can do is restrict a user from logging in twice.
The problem is that "another place" doesn't help anyone: all the users in a single company are likely to "share" the same IP address so if your user logs in on the ground floor and then takes the elevator to the 34th he will get the same IP address as far as you are concerned.

You can "prevent" double log in, by recording the last login / use time, and checking if he has explicitly logged out, or a period slightly longer than the Session duration has passed before allowing another log in. But really, that's about your limit - you can't rely on users to log out because circumstances can prevent that, such as a power cut or equipment failure so you have to provide a timeout period to let them login again.
 
Share this answer
 
 
Share this answer
 
You have to build logic in your application to handle this scenario.

Simplest solution is track each login (with the time) in a database.
If the user logins from any other location check this table and display a message.

You will need a clean up job to empty this table after some time.
 
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