Jump to content

Archived

This topic is now archived and is closed to further replies.

liboration77

Timed Unlock

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.