Jump to content

Timed Unlock


liboration77

Recommended Posts

I am making a login script that locks a user account for 15 minutes if someone fails to login correctly after 5 attempts. It works, however, I do not know how to unlock it 15 minutes later.

My original thought would be to store in the database the time at which the account was locked. Then everytime someone tried to log into the locked account it would check to see if the current time is 15 minutes or more past the time at which the account was locked.

My problem is I have no idea on how to successfully compare two times like this. Any ideas?
Link to comment
Share on other sites

Your idea is great. When you "lock" a user enter the current timestamp (by simply using the returned value from the function [url=http://www.php.net/manual/en/function.time.php]time()[/url]) into the database.
Then, in every log in attempt check if the current timestamp (run time() again :)) minus the timestamp in the database is greater than 15*60 (15minutes * 60 seconds). If it is, let the user log in. If it's less that means the 15 minutes of "locking time" haven't passed yet :)

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.