在您的php
中,您可以执行以下操作(伪代码)
# clear old counters
if last_login_attempt_time > 5_mins_ago
$_SESSION['count'] = 0
# redirect if counter high
if $_SESSION['count'] >= 3
send_client_to(error_page)
die() # ensure code proceeds no further
# getting here means that attempting a log in is okay for this session
# attempt login
if login_unsuccessful
$_SESSION['count'] += 1
reload_this_page()
else
continue_as_normal()
在您的error_page
(still php
) 中,如果您想指出他们需要等待多长时间
remain = 5_minutes + last_login_attempt_time - time_now
if remain > 0
# tell client to wait for remain time
else
# tell client they don't have to wait
如果你想让倒计时动画化,你可以将 的值传递remain
给一些JavaScript并error_page
让它做一个视觉倒计时JavaScript。这只是为了视觉效果,与用户何时可以实际登录无关。