在一个忘记密码的环境中,我希望能够将输入电子邮件地址的尝试限制为 10 次。我的第一个想法是使用 cookie。
$attempts = 0;
if( isset( $_COOKIE['password_recovery_attempts'] ) )
$attempts = $_COOKIE['password_recovery_attempts'];
if( $pass === false ){
$val = $attempts + 1;
setcookie( 'password_recovery_attempts', $val, time() + 86400 ); //86400 = 1 day
}
if( $attempts > 9 ){
echo 'You have attempted to reset your password too many times';
return false;
}
我对只使用 cookie 的担忧是,cookie 很容易被删除。这里有什么更好的做法?