最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
代码例子 - Ask For Login
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
This sample shows you how to setup some of your pages to ask for login if the user has not logged in yet.
2eNetWorX/dev site uses this kind of protection for interactive pages and file downloads.
Let's assume that we have a page where the visitors can ask questions. We want to make sure that the user has logged in before being able to ask a question.
If the user has not logged in yet, we will ask for a login. After a successful login, we will redirect the user to the page requested.
First, we will have a common file to check for login. You need to include this file into all the pages that require login.
security.asp
<%
bLoggedIn = (len(session("UserName")) > 0)
if bRequireLogin then
'Login required
if Not bLoggedIn then
'Not logged in, ask for login
response.redirect "login.asp?comebackto=" & _
request.servervariables("script_name") & "?" & _
server.urlencode(request.querystring)
'Note how we construct the page to come back
end if
end if
%>
login.asp
First thing to do in our login.asp page is to get the page where the user is redirected from. The variable sReferer is used to redirect back to the page the user has come from.
sGoBackTo variable will used in the
-
上一个: asp中的一个奇怪的函数
-
下一个: 用户状态维护
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14