Hello!,
I have an application written in PHP and Javascript.
How do I prevent the users from logging in if the user is already logged in? This is to prevent the users from using same account at the same time.
Thanks!
Pevent user from using the same account
Moderator: General Moderators
Simply.... when the user logs in, turn on some flag in your database. Let's say, add a new field to your database: online. When someone tries to log in you check if this flag is "on" or "off", if it's "off" you log him in and change it to "on"; if it's already "on" you give him an error message and you don't log him in.
- jlising
- Forum Commoner
- Posts: 33
- Joined: Mon Mar 19, 2007 1:48 am
- Location: Pampanga, Philippines
- Contact:
Thanks!
I made a flag field 'online'. This field is marked 'on' every time the user logs in. My concern is, what if the user does not log out properly instead he/she close the browser. I believe the value of the 'online' field will be orphaned with value 'on'. So, the next time the user wants to log, an error message will appear.
Is there a way to prevent this kind of situation? Can I restrict user from improper logout?
I made a flag field 'online'. This field is marked 'on' every time the user logs in. My concern is, what if the user does not log out properly instead he/she close the browser. I believe the value of the 'online' field will be orphaned with value 'on'. So, the next time the user wants to log, an error message will appear.
Is there a way to prevent this kind of situation? Can I restrict user from improper logout?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia