i need help for limiting login attempt of the user. this is my code.
$login = login($username, $password);
if($login === false) {
if(isset($_COOKIE['login'])){
if($_COOKIE['login'] < 3){
$attempts = $_COOKIE['login'] + 1;
setcookie('login', $attempts, time()+60*10); //set the cookie for 10 minutes with the number of attempts stored
$errors[] = 'That username/password combination is incorrect!';
} else{
echo 'You are banned for 10 minutes. Try again later';
}
} else {
setcookie('login', 1, time()+60*10); //set the cookie for 10 minutes with the initial value of 1
}
} else {
$_SESSION['user_id'] = $login;
header('Location: ../../home.php');
exit();
}
it looks right for me but it just wont work. the user could still access his/her account even after attempting 3 login.