asp程序如何添加用户登陆超时的代码

asp程序如何添加用户登陆超时的代码,第1张

紫灵物语说"你把IsEnd的值改了

再试试"是不对的

调用:<%ClsPubCheckTimeOut(1)%>为判断已登录用户是否无 *** 作登录超时的,若该了isEnd的值程序将会当作未登录用户处理

此外应该设置SessionTimeOut的值为5个小时,即300分钟

故在用户登录时应设置<%SessionTimeOut=300%>

应修改如下:

<%

Session(SessionPre&"UserName")=Username

Session(SessionPre&"UserGroup")=TempValue(3,0)

SessionTimeOut=300

ResponseRedirect

"Userasp"

%>

另外,站长团上有产品团购,便宜有保证

responseCookies("jiaban")expires ="2008-09-20" 这个过期了吧。另外不建议用Cookies如果用户的浏览器关闭了javascript就出错了,一般用session比较好的(个人意见呵呵)。

这个是我用DW写的一个管理后台,能够禁止非法地址及非登陆用户访问

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<%

' Logout the current user

MM_Logout = CStr(RequestServerVariables("URL")) & "MM_Logoutnow=1"

If (CStr(Request("MM_Logoutnow")) = "1") Then

SessionContentsRemove("MM_Username")

SessionContentsRemove("MM_UserAuthorization")

MM_logoutRedirectPage = "indexasp"

' redirect with URL parameters (remove the "MM_Logoutnow" query param)

if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(RequestServerVariables("URL"))

If (InStr(1, UC_redirectPage, "", vbTextCompare) = 0 And RequestQueryString <> "") Then

MM_newQS = ""

For Each Item In RequestQueryString

If (Item <> "MM_Logoutnow") Then

If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"

MM_newQS = MM_newQS & Item & "=" & ServerURLencode(RequestQueryString(Item))

End If

Next

if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS

End If

ResponseRedirect(MM_logoutRedirectPage)

End If

%>

<!--#include file="Connections/connasp" -->

<%

' Edit Operations: declare variables

Dim MM_editAction

Dim MM_abortEdit

Dim MM_editQuery

Dim MM_editCmd

Dim MM_editConnection

Dim MM_editTable

Dim MM_editRedirectUrl

Dim MM_editColumn

Dim MM_recordId

Dim MM_fieldsStr

Dim MM_columnsStr

Dim MM_fields

Dim MM_columns

Dim MM_typeArray

Dim MM_formVal

Dim MM_delim

Dim MM_altVal

Dim MM_emptyVal

Dim MM_i

MM_editAction = CStr(RequestServerVariables("SCRIPT_NAME"))

If (RequestQueryString <> "") Then

MM_editAction = MM_editAction & "" & ServerHTMLEncode(RequestQueryString)

End If

' boolean to abort record edit

MM_abortEdit = false

' query string to execute

MM_editQuery = ""

%>

<%

' Delete Record: declare variables

if (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

MM_editConnection = MM_conn_STRING

MM_editTable = "ip"

MM_editColumn = "ID"

MM_recordId = "" + RequestForm("MM_recordId") + ""

MM_editRedirectUrl = "guanliasp"

' append the query string to the redirect URL

If (MM_editRedirectUrl <> "" And RequestQueryString <> "") Then

If (InStr(1, MM_editRedirectUrl, "", vbTextCompare) = 0 And RequestQueryString <> "") Then

MM_editRedirectUrl = MM_editRedirectUrl & "" & RequestQueryString

Else

MM_editRedirectUrl = MM_editRedirectUrl & "&" & RequestQueryString

End If

End If

End If

%>

<%

' Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

' create the sql delete statement

MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then

' execute the delete

Set MM_editCmd = ServerCreateObject("ADODBCommand")

MM_editCmdActiveConnection = MM_editConnection

MM_editCmdCommandText = MM_editQuery

MM_editCmdExecute

MM_editCmdActiveConnectionClose

If (MM_editRedirectUrl <> "") Then

ResponseRedirect(MM_editRedirectUrl)

End If

End If

End If

%>

<%

' Restrict Access To Page: Grant or deny access to this page

MM_authorizedUsers=""

MM_authFailedURL="logoinasp"

MM_grantAccess=false

If Session("MM_Username") <> "" Then

If (true Or CStr(Session("MM_UserAuthorization"))="") Or _

(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then

MM_grantAccess = true

End If

End If

If Not MM_grantAccess Then

MM_qsChar = ""

If (InStr(1,MM_authFailedURL,"") >= 1) Then MM_qsChar = "&"

MM_referrer = RequestServerVariables("URL")

if (Len(RequestQueryString()) > 0) Then MM_referrer = MM_referrer & "" & RequestQueryString()

MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & ServerURLEncode(MM_referrer)

ResponseRedirect(MM_authFailedURL)

End If

%>

<%

Dim Recordset1

Dim Recordset1_numRows

Set Recordset1 = ServerCreateObject("ADODBRecordset")

Recordset1ActiveConnection = MM_conn_STRING

Recordset1Source = "SELECT ID, IP, NAME FROM ip ORDER BY ID ASC"

Recordset1CursorType = 0

Recordset1CursorLocation = 2

Recordset1LockType = 1

Recordset1Open()

Recordset1_numRows = 0

%>

<%

Dim Repeat1__numRows

Dim Repeat1__index

Repeat1__numRows = -1

Repeat1__index = 0

Recordset1_numRows = Recordset1_numRows + Repeat1__numRows

%>

<%

Dim MM_paramName

%>

<%

' Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone

Dim MM_keepURL

Dim MM_keepForm

Dim MM_keepBoth

Dim MM_removeList

Dim MM_item

Dim MM_nextItem

' create the list of parameters which should not be maintained

MM_removeList = "&index="

If (MM_paramName <> "") Then

MM_removeList = MM_removeList & "&" & MM_paramName & "="

End If

MM_keepURL=""

MM_keepForm=""

MM_keepBoth=""

MM_keepNone=""

' add the URL parameters to the MM_keepURL string

For Each MM_item In RequestQueryString

MM_nextItem = "&" & MM_item & "="

If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then

MM_keepURL = MM_keepURL & MM_nextItem & ServerURLencode(RequestQueryString(MM_item))

End If

Next

' add the Form variables to the MM_keepForm string

For Each MM_item In RequestForm

MM_nextItem = "&" & MM_item & "="

If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then

MM_keepForm = MM_keepForm & MM_nextItem & ServerURLencode(RequestForm(MM_item))

End If

Next

' create the Form + URL string and remove the intial '&' from each of the strings

MM_keepBoth = MM_keepURL & MM_keepForm

If (MM_keepBoth <> "") Then

MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)

End If

If (MM_keepURL <> "") Then

MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)

End If

If (MM_keepForm <> "") Then

MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

End If

' a utility function used for adding additional parameters to these strings

Function MM_joinChar(firstItem)

If (firstItem <> "") Then

MM_joinChar = "&"

Else

MM_joinChar = ""

End If

End Function

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 10 Transitional//EN" ">

分类: 电脑/网络 >> 程序设计 >> 其他编程语言

问题描述:

做三个页面:denglu,zuche,lianjie,若用户已注册,就执行lianjie,若没注册,就执行zuche。登录页面只有一个表单,表单中有一个按钮“登录”和两个文本域:用户名和密码。如何编写ASP代码

解析:

设login为登陆页面login1为login所提交的页面(代码验证页面),login1里的代码

开库

<!--#include file="conn"-->

<%

先接login页面的值

admin_name(这个是用户名)=serverencode(trim(request("admin_name(这个是login的帐号文本框的名字)")))

admin_code(用户的密码)=serverencode(trim(request("admin_code"(这个是login的密码文本框的名字))))

开数据库

sql="select from admin where admin_name='"&admin_name&"' and admin_code='"&admin_code&"'"

rsopen sql,conn

判断

if not rseof then

如果数据库里有值,则发通行证,并页面跳转

session("admin_name")=admin_name

responseredirect("admin")

否则还在登陆页面

else

responseRedirect("login")

end if

%>

登陆页面头部加上这句验证通行证是否有效的代码

<%

if session("admin_name(用户的帐号名)")="" then

responseredirect("login")

end if

%>

差不多了,应该是可以了,我也只学了皮毛呵,如果不行再找高人吧,我才学ASP两个星期,很多都不懂,正好你的问题是我昨天的作业,复制给你了。再见,我的QQ是,以后有空,大家一起讨论吧。。

以上就是关于asp程序如何添加用户登陆超时的代码全部的内容,包括:asp程序如何添加用户登陆超时的代码、ASP.NET+ACCESS编写的用户注册登录程序问题、ASP的网站后台登录管理程序怎连接到管理界面,用Session限制管理界面等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10091868.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存