用cookie
IF Request.Cookies("web")("loginErrTimes")="" THEN
Response.Cookies("web")("loginErrTimes")="1"
Response.Cookies("web").Expires=now()+1 '+1表示当前时间后1天,如果是1个小时后就是+1/24
END IF
IF cint(Request.Cookies("web")("loginErrTimes"))>=3 THEN
Error=Error+"<li>尝试登录出错已经达到3次,24小时内无法再登录了</li>"
ELSE
Error=Error+"<li>用户名或密码错误,请仔细核对!</li>"
Error=Error+"<li>您还有"&cstr(3-cint(Request.Cookies("web")("loginErrTimes")))&"次可以尝试的机会</li>"
Response.Cookies("web")("loginErrTimes")=cstr(cint(Request.Cookies("web")("loginErrTimes"))+1)
END IF
====================================================================
用Session
if Session("err")>=3 then
errorr=1
errmsg="你已经重试这么多次了,累了吧,请歇会再来,或者联系管理员!"
else
sql="select * from admin where adminname='"&adminname&"'"
Rs.open sql,conn,3,1
if Rs.eof and Rs.bof then
errorr=1
Session("err")=Session("err")+1
errmsg="用户名不存在,请返回重新填写确认!"
Rs.close
else if adminpassword<>Rs("adminpassword") then
errorr=1
Session("err")=Session("err")+1
errmsg="用户名和密码不符,请确认后再输一次!"
Rs.close
end if
end if
=================================================================
用事件表。()
event_logintimes(
id int identity(1,1) primary key,
username nvarchar(20) foreign key references userinfo(username) on update cascade,--用户名
loginTime smalldatetime --登录次数
)
用户登录不成功就对其进行计数
当计数到3次时就将该用户名记录到一个专门记录该事件的表中,并把时间也一起记录。
当用户再次登录的时候先看该事件表中是否存在该用户,如果不存在就进行一般性的验证,如果存在就与表中的时间进行比较。如果时间相关大于一个小时就进行验证,否则提示用户无法进行登录
发表于 @ 2008年04月16日 21:19:00|评论(loading...)|编辑