当前位置:编程学习 > asp >>

请问asp安全退出代码怎么写?

我有一个网站系统后台没有退出功能,我想自己添加,相关代码如下:

<%
session("aname")<>""
Session("apass")<>""
Session.Abandon
response.write"<SCRIPT language=JavaScript>alert('成功退出登录,正在返回首页!');"
response.write"this.location.href='../index.asp';</SCRIPT>"
%>

可是点退出按钮后,实际上只退出了一部分,左边的后台管理菜单还在显示,而且网址也没有跳转到首页,只是中间的网页跳到了首页!请哪位朋友帮忙看下是什么问题?是不是session、Cookies方面没有清掉还是...?
答案:
"实际上只退出了一部分,左边的后台管理菜单还在显示,而且网址也没有跳转到首页,只是中间的网页跳到了首页!"
这应该是用了iframe吧?把你的代码中的this.location.href改成parent.location.href就可以了
<% 
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
Session.Contents.Remove("username")
Session.Contents.Remove("MM_UserAuthorization")
MM_logoutRedirectPage = "login.asp"'退出后的页面
' redirect with URL parameters (remove the "MM_Logoutnow" query param).
if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_newQS = "?"
For Each Item In Request.QueryString
If (Item <> "MM_Logoutnow") Then
If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
End If
Next
if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
End If
Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="login.asp"'进入失败转向的页面
MM_grantAccess=false
If Session("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 = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>

<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href=><script language="JavaScript" src="js.js"></SCRIPT>
</head>
<body text="#000000">
<div align="center"> <a href=></div>
</body>
</html>

以上是dreamweaver生成的
redirect "../index.asp"

上一个:asp.net代码问题求助
下一个:asp.net 视频播放代码

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,