Connecting Tech Pros Worldwide Help | Site Map

prevent duplicate login

  #1  
Old July 1st, 2009, 10:07 AM
Newbie
 
Join Date: Jan 2007
Posts: 28
Dear All,

I would like to ask about login control. One of my I have to prevent the user duplicate login. I would like to know it is possible or not? If possible, could you tell me some logic for this.

Thanks all,
  #2  
Old July 1st, 2009, 12:03 PM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,858
Provided Answers: 9

re: prevent duplicate login


Quote:
Originally Posted by foekall View Post
Dear All,

I would like to ask about login control. One of my I have to prevent the user duplicate login. I would like to know it is possible or not? If possible, could you tell me some logic for this.

Thanks all,
Could you please explain the scenario a little more?
  #3  
Old July 1st, 2009, 03:16 PM
Newbie
 
Join Date: Jan 2007
Posts: 28

re: prevent duplicate login


Quote:
Originally Posted by Markus View Post
Could you please explain the scenario a little more?
My scenario is just simple. I am writing admin control for booking system. I create only one account for admin login but there are one or more user use this admin control with one account. I want to give permission to access admin control only one user at a time.

Thanks
  #4  
Old July 1st, 2009, 05:14 PM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,858
Provided Answers: 9

re: prevent duplicate login


Quote:
Originally Posted by foekall View Post
My scenario is just simple. I am writing admin control for booking system. I create only one account for admin login but there are one or more user use this admin control with one account. I want to give permission to access admin control only one user at a time.

Thanks
This is difficult because there is no reliable way to *know* when someone logs out. Sure, they may use a 'logout' facility on your application, but they may also -- and this is much more likely -- just close the browser, and, if they do, then you (the application) are left unaware.

There is a way to overcome this, although, again, it is not perfect nor precise.

When a user (admin) logs in, you update a flag (logged_in) in your database to true. You also log the datetime of the log in (see datetime - mysql). If a user decides to use the logout facility, update the database flag to reflect this.

Now onto the 'knowing when a user is logged out'.

Everytime your admin account performs an action (deletes record, creates record, etc), you update the datetime column to the current datetime. Now we have a general understanding of the admin accounts last activity.

When a user attempts to login as admin, you first check if there is someone already logged in (logged_in). If there is, you compare the last activity time to the current time. You then decide how long someone should have remained inactive before being flagged as logged out. If the last activity time is greater than the specified time, allow the person attempting to log in that priviledge.

Any questions?
  #5  
Old July 1st, 2009, 08:00 PM
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,075

re: prevent duplicate login


Depending on your level of paranoia =), you could have a cron job that checks all the dates and logs all users off (let's say setting a logged_in field value to false) if the last activity time (like Markus) suggested is older than a specified period, like an hour.

Makes sense?



Dan
  #6  
Old July 1st, 2009, 09:28 PM
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,858
Provided Answers: 9

re: prevent duplicate login


Quote:
Originally Posted by dlite922 View Post
Depending on your level of paranoia =), you could have a cron job that checks all the dates and logs all users off (let's say setting a logged_in field value to false) if the last activity time (like Markus) suggested is older than a specified period, like an hour.

Makes sense?



Dan
OMG! I was supposed to suggest that but completely forgot.

:D
  #7  
Old July 1st, 2009, 11:25 PM
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,075

re: prevent duplicate login


Quote:
Originally Posted by Markus View Post
OMG! I was supposed to suggest that but completely forgot.

:D
Just admit it!, you can't be as good as me!! :P

BOW before the master!!

/jk




Dan
  #8  
Old July 2nd, 2009, 02:43 AM
Newbie
 
Join Date: Jan 2007
Posts: 28

re: prevent duplicate login


Dear all,

Thanks for yours advice. I will try with datetime according to yours advice. If I have any question, I would like to ask again. :)

Thanks
foekall
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to prevent query/form from being read-only beacon answers 11 September 7th, 2009 11:18 PM
MySQL error reporting Paul Furman answers 8 April 24th, 2007 10:05 PM
Prevent Multiple login in ASP.NET Bhavini answers 6 November 30th, 2006 10:05 PM
Sessions and closing the browser Theo answers 22 July 17th, 2005 09:53 AM