有时我们要限制用户重复刷新一个页面。很多站点对于录入操作都用验证码来限制恶意灌水。但是如果是在一套web管理系统中,执行一段没有界面的逻辑操作代码时,就不能用验证码了。我们一般用session来限制。下面就是一个包装的函数,用法很简单。
操作限制函数
塞北的雪 制作
www.knowsky.com
sessionname session的名字
secondspan 时间间隔(单位:秒)
function candorepeat(sessionname,secondspan)
xx=timer()
if session(sessionname)=”” then
session(sessionname)=xx
else
if xx-session(sessionname)<secondspan then
candorepeat=false
else
session(sessionname)=xx
candorepeat=true
end if
end if
end function