liboration77 Posted October 26, 2006 Share Posted October 26, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/25198-timed-unlock/ Share on other sites More sharing options...
.josh Posted October 26, 2006 Share Posted October 26, 2006 convert it to unix timestamp format and just do a regular comparison. look at the mktime function Quote Link to comment https://forums.phpfreaks.com/topic/25198-timed-unlock/#findComment-114868 Share on other sites More sharing options...
Orio Posted October 26, 2006 Share Posted October 26, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25198-timed-unlock/#findComment-114869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.