Current location: Hot Scripts Forums » Programming Languages » PHP » Preventing multiple user from loging in using the same username and password


Preventing multiple user from loging in using the same username and password

Reply
  #1 (permalink)  
Old 09-14-05, 01:12 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Question Preventing multiple user from loging in using the same username and password

Goal: Preventing multiple user login using the same username & password from different location (Simoltanous Login)

Options Available:

1) IP Checking: One way to prevent multiple people from using the same account to gain access to a restricted area of a site is to store their IP address in a database table, along with the "time()" they first logged in. You would then have to check the users IP address on subsequent pages against the value stored in the database to make sure that the user is still using the same IP to view the page. If the user has a different IP, we would prevent the user from login in and display a message saying "You are Currently Logged In from Another Location! Please Log from the other location and try again" (or something like that). This check is usually done at given time intervals (say every 5 minutes or so)

Problem with Method: Several Internet Service Providers like AOL, change the users IP Address every few minutes. So this could potentially lock your REAL user out of the system as well.

2) Session ID Tracking: A similar idea to method 1, except that you would store the SESSION ID in the database, and instead of checking the IP, you would then compare the users SESSION ID to verify that the user is still the same user. The advantage of thsi method is that it does not depend on the users IP. Therefore AOL users will not have a problem with this login system.

Problem with Method: Although the SESSION ID is unique for current active user, it can be assigned by server to any other later on. Plus you may have problems with Session ID based login system, if you use a shared Webhost.

3) Boolean Login Field: With this method, you would basically create a boolean field in your database, and set the value to TRUE if the user is logged in, or false if the user is not. Again, to check if the user is still logged in, you would have to use a timestamp like previous methods to see if the user has been inactive for more then a specific period of time, and reset the Boolean database field value to false if the user is inactive (This could basically either mean that the user just closed his web browser and left, or that he took a longer then usual lunch break and forgot about your site).

Problem with Method: The basic problem with this method (as with the other two methods), is that if you set a time period (say 5 minutes) to give the visitor to go to the next page and verify that he is still alive and on your site, if the visitor takes longer then 5 minutes to move on to the next page, he will be locked out of the system for ANOTHER 5 minutes (until the system clears the hold on his account).

THE QUESTION:

Here is my main question about this whole issue. Is there a better way of performing this task that will not require the setting of a time interval to see if the user is still logged in? IS THERE A GOOD SOLUTION TO THIS ISSUE???

ANY Comments would be appreciated.
__________________
Reply With Quote
  #2 (permalink)  
Old 09-14-05, 01:51 PM
nekeno12 nekeno12 is offline
Wannabe Coder
 
Join Date: May 2004
Location: CO
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
Use mysql to store you sessions, and upon a new login, check the session table to see if the username already exists.

If so, then you deny access.

Simple and safe.
Reply With Quote
  #3 (permalink)  
Old 09-14-05, 01:53 PM
nekeno12 nekeno12 is offline
Wannabe Coder
 
Join Date: May 2004
Location: CO
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
I actually built a session file analyzer for my system. It actually parses through all the session files in /tmp directory, breaks down the session data and performs the tasks it needs to.

The positive in doing it this way is not having to build your sessions in mysql.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing multiple logins bob23 PHP 4 04-30-09 10:33 PM
looking for a shoping cart has a sign up form with username and password they choose. kicon Script Requests 1 11-03-04 11:15 AM
need help with username password of os traceMe ASP 0 08-23-04 03:19 AM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 12:00 PM
script to generate random username, password, etc. mangled Script Requests 1 01-19-04 07:15 PM


All times are GMT -5. The time now is 06:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.