NerdConcepts Posted January 12, 2008 Share Posted January 12, 2008 I am trying to figure out the best way to make sure only one user is logged in to each account on my website. I thought about using database to do this, but then if the user doesn't logout I don't know of a way to automatically (when the browser is closed, or session timeout) the database entry changes to reflect this. My other thought was to do a custom session variable with the user ID in it. Then when someone tries to login and it sees that, that user_id has already been assigned a session it won't allow another login. Is there a way to do this? Link to comment https://forums.phpfreaks.com/topic/85697-one-user-logged-in-per-account/ Share on other sites More sharing options...
therealwesfoster Posted January 12, 2008 Share Posted January 12, 2008 Have a column in your user's row named "user_online" or something like that. And when processing the login, check if "user_login" == 1 (if the user is already online), if it is, then don't allow the login. If it == 0 (user not online), then allow the login. Then, have an activity timeout (every 15 minutes of inactivity or so), and set user_online to 0 (and log the user out). Get what i'm saying? that would work, and if a login cookie is present, you can set user_online to 1. Link to comment https://forums.phpfreaks.com/topic/85697-one-user-logged-in-per-account/#findComment-437372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.