如何实现强制登录?

2023-12-05 0 140

security.asp

<%

bLoggedIn = (len(session(\”UserName\”)) > 0)

if bRequireLogin then

\’ 要求登录.

if Not bLoggedIn then

response.redirect \”login.asp?comebackto=\” & _

request.servervariables(\”script_name\”) & \”?\” & _

\’ 如果没注册,请注册.

server.urlencode(request.querystring)

end if

end if

%>

 

login.asp

<%

if request(\”comebackto\”) <> \”\” then

sReferer = request(\”comebackto\”)

sGoBackTo = \”?\” & request.querystring

end if

if request(\”cmdLogin\”) <> \”\” then

sUserName = request(\”txtUserName\”)

sPassword = request(\”txtPassword\”)

\’ 提交注册.

if sUserName = \”bill\” And sPassword = \”gates\” then

bLoginSuccessful = True

\’ 验证帐号和密码.

end if

session(\”UserName\”) = sUserName

if sReferer = \”\” then

response.redirect \”index.asp\”

\’ 登录成功,到用户请求页.

else

response.redirect sReferer

\’ 如果没填写,重定向到登录页或其他约定的页.

end if

else

%>

<form action=\”login.asp<%=sGoBackTo%>\” method=\”post\”>

<input type=\”text\” name=\”txtUserName\”><br>

<input type=\”password\” name=\”txtPassword\”><br>

<input type=\”submit\” name=\”cmdLogin\”><br>

</form>

\’ 显示登录.

<%

end if

%>

testpage.asp

<%

bRequireLogin = True

%>

<!–#include file=\”security.asp\”–>

\’ bRequireLogin设为真,放到 security.asp .

[1]

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 编程10000问 如何实现强制登录? https://www.u-9.cn/biancheng/bc10000/96049.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务