欢迎来到代码驿站!

当前位置:首页 >

如何实现强制登录?

时间:2022-10-24 08:52:34|栏目:|点击:

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]

上一篇:使用VirtualBox和Vagrant搭建Linux环境的方法步骤

栏    目:

下一篇:Rainbond应用分享与发布官方文档说明

本文标题:如何实现强制登录?

本文地址:http://www.codeinn.net/misctech/217186.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有