Connecting Tech Pros Worldwide Forums | Help | Site Map

single connection per user on platform

Newbie
 
Join Date: Feb 2008
Posts: 20
#1: Jul 11 '08
Hello all!

I have asked the question at the apache forum but I have gotten no replies so I need to ask someone here in case you know how I can solve the following problem:

I am working on a platform and there is a restricted area when users need to login. The issue is that multiple users can login with the same username/password at the same time which I don't like. I want when a user logs in no other person to be able to log in the system with the same username/password. Is there a way I can implement that on the server? I have tried to implement the operation with php but it does not work right. I would highly appreciate any help.

Thank you
Theoni

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Jul 12 '08

re: single connection per user on platform


Heya, Theoni.

You need to be able to uniquely identify each computer. My recommendation is to use a cookie.

Unfortunately, session cookies are rather unreliable, and IP addresses are not particularly unique.

You'll want to set a cookie when the User logs in with a unique identifier (sha1(microtime()) does nicely). The next time that User tries to log in, check his Username, password AND unique ID to see if he's allowed to login from that machine.

Make sure you implement a timeout so that the User isn't stuck on one machine until he logs out!
Newbie
 
Join Date: Feb 2008
Posts: 20
#3: Jul 13 '08

re: single connection per user on platform


Quote:

Originally Posted by pbmods

Heya, Theoni.

You need to be able to uniquely identify each computer. My recommendation is to use a cookie.

Unfortunately, session cookies are rather unreliable, and IP addresses are not particularly unique.

You'll want to set a cookie when the User logs in with a unique identifier (sha1(microtime()) does nicely). The next time that User tries to log in, check his Username, password AND unique ID to see if he's allowed to login from that machine.

Make sure you implement a timeout so that the User isn't stuck on one machine until he logs out!


I did try such an implementation but I am not sure that session cookies cover all cases for users this is why I was looking for a more elaborate solution that takes care of user connection on the server, without interference. I will look into your suggestion better if I don't come up with anything better.

thank you for the answer pbmods
theoni
Reply