Page 1 of 1

User login, one at a time

Posted: Mon Aug 06, 2007 8:46 pm
by pettazz
I've been using php for a few years now, but this is one problem that Google and my usual searches havent solved for me yet.

I have a system which users can log in and out of, with user info stored in mySQL and passing some cookie-based session data around.

But I want to make sure that when someone logs in as, for example, jose, there can only be one jose logged in at a time. More than one seperate user can be on at once, but not the same user from different locations.

I can think of plenty of ways to keep track of when a user logs in and out and implement this...but the problem is what if a user doesn't properly log out using the log out button, instead just going somwhere else or closing the browser.

That's where all my solutions fall apart.

Does anyone have any suggestions?

Re: User login, one at a time

Posted: Mon Aug 06, 2007 9:03 pm
by superdezign
pettazz wrote:I've been using php for a few years now, but this is one problem that Google and my usual searches havent solved for me yet.

I have a system which users can log in and out of, with user info stored in mySQL and passing some cookie-based session data around.

But I want to make sure that when someone logs in as, for example, jose, there can only be one jose logged in at a time. More than one seperate user can be on at once, but not the same user from different locations.

I can think of plenty of ways to keep track of when a user logs in and out and implement this...but the problem is what if a user doesn't properly log out using the log out button, instead just going somwhere else or closing the browser.

That's where all my solutions fall apart.

Does anyone have any suggestions?
Handle sessions through the database, and have a column that stores the user id. Then, whenever a user logs in, log out the previously logged in user by replacing the entry.

Posted: Mon Aug 06, 2007 9:08 pm
by pettazz
Thanks a lot!

There's still a lot of php i've yet to learn, looks like this is a great place to find help on it.