标题: ASP的session问题! [打印本页] 作者: 芯頽廢.。﹖ 时间: 2009-9-15 00:00 标题: ASP的session问题! [我自己做的后台登陆系统!可是SESSION变量不可以用!
我的登陆文件!LOGIN.ASP:
<%
if request("action")="adminlogin" then
s=Trim(Request.Form("s"))
s2=Request.Form("s2")
If s2<>s Then
Response.Write("<script language=javascript>alert('请输入正确的认证码!');this.location.href='login.asp';</script>")
Response.End
end if
Function ReplaceBadWord(g_word)
g_word=Replace(g_word,"'","")
g_word=Replace(g_word," ","")
g_word=Replace(g_word,"&","")
g_word=Replace(g_word,"(","")
g_word=Replace(g_word,"\","")
g_word=Replace(g_word,"/","")
g_word=Replace(g_word,"..","")
g_word=Replace(g_word,"^","")
g_word=Replace(g_word,"#","")
g_word=Replace(g_word,"%","")
g_word=Replace(g_word,"|","")
g_word=Replace(g_word,";","")
g_word=Trim(Replace(g_word,")",""))
ReplaceBadWord=g_word
End Function
ADMIN_NAME=ReplaceBadWord(Request.form("adminname"))
ADMIN_PASS=Md5(ReplaceBadWord(Request.form("adminpwd")))
if ADMIN_NAME="" OR ADMIN_PASS="" then
Response.Write("<script language=javascript>alert('请输入用户名或密码!');this.location.href='login.asp';</script>")
Response.End
end if
sql="select * from admin where admin_name='"&ADMIN_NAME&"' and admin_pass='"&ADMIN_PASS&"'"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
rs.close
set rs=nothing
Response.Write("<script language=javascript>alert('您输入的用户名和密码不正确\n 请重新输入!');this.location.href='login.asp';</script>")
else
response.cookies("admin")=rs("admin_name")
session("adminlogin")="ok"
session("admin_type")=rs("admin_type")
Session("admin")=rs("admin_name")
Session("lock")=rs("lock")
session.timeout=10
response.redirect "admin_index.asp"
rs.close
set rs=nothing
end if
end if
dim s
randomize timer
s=Int((8999)*Rnd +1000)
后台管理首页admin_index.asp:
<!--#include file="admin_config.asp"-->
<HTML>
<HEAD>
<TITLE><%=webname%></TITLE>
</HEAD>
<%
if session("administrator")<>"ok" then
response.Write "你没有登陆或者登陆以超时!\n请重新<a href='login.asp'><FONT COLOR=#FF0000>登陆</a>"
response.end
end if