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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.