[UPHPU] Best way to prevent multiple logins from the same account.

John David Anderson uphpu at johndavidanderson.net
Thu Apr 5 18:35:04 MDT 2007


On Apr 5, 2007, at 5:59 PM, phpninja wrote:

> Hello all, I have been hacking some code around to see if it is  
> possible to
> prevent multiple logins from the same account. That is, if username/ 
> password
> is currently logged in, and someone opens another web browser and  
> tries to
> login with that same username/password it will then redirect them out,
> saying that someone from your account is already currently logged in.
>
> I thought the best way of doing this would be adding a logged_in  
> field to my
> users table and when they complete a successful login, set the  
> field to yes.
> And then update it the field appropriately if someone clicks  
> "logout" it
> would just set the field to no. My problem is when a user click the X
> button, or hits alt + 4, I do not think javascript can pick that up  
> right to
> set the logged in status to no via xmlhttp. has anyone figured this  
> out, or
> is it not possible the way I am trying to do it? Thanks in advance.

I like to check the user's IP address and user-agent string during  
session registration. That helps quite a bit as well.

-- John


More information about the UPHPU mailing list