One Logged-in User

Hi all, I have a login system and want to allow only one username to be logged-in at one time, so basically the user can’t log on to two computers at the same time. I’m doing this by updating my table when the user logs in and then updating it again when they log out - like this all is working perfectly.

Problem is when the user closes the browser without logging out, obviously the update database query isn’t ran and therefore the user is locked out of the system.

What’s the best workaround for this?

If they try to log in more than half an hour (or an hour, or …) after their last activity of the previous login, assume they logged out of that previous login.

Hi, thank you for your prompt reply. Is there any way this can be achieved by perhaps using cookies instead?

Not as far as I know, but what did you have in mind?

Hey there, I’ve created a POS system for my work. Each employee has their own username, etc for writing orders. I’ve been asked if I can make it so that a user can only be logged in on once machine - I did this manage to do this but the problem is if the user just shuts their browser then the user is effectively locked out of the system. Just trying to figure out a workaround for this?

Yes I got that. See my reply in post #2.
I’m not sure what you’re asking for more? Something with cookies?

confused

Hey bud, no worries. Think I’ve managed to add a timer as you mentioned. Apologies for the delay in responding to your message! Cheers dude :slight_smile:

A better way than locking the account for e.g. half an hour (it has to be locked at least as long until the old session expired anyway) would be to show a message to the user that there’s still an active session.
You could then give an option to cancel the old session to log in from the other PC or to cancel the login process.
This way a user can be logged in on one PC but still switch PCs very easily without having to wait until the old session expires.
No employer would like to see his employees sitting in front of an unusable POS system waiting that they can log in again :slight_smile:

Hey bud, thanks for the message. Ok, sounds an interesting concept. What would be the best way to cancel and log out the old session?