有时我们要限制用户重复刷新一个页面。很多站点对于录入操作都用验证码来限制恶意灌水。但是如果是在一套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
|