新微赢技术网

标题: 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

%>
<frameset rows="*,25" frameborder="NO" border="0" framespacing="0">
<frameset rows="*" cols="175,10,*" id="frame">
    <frame src="left.asp" name="leftFrame" noresize="noresize" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" />
        <frame src="center.asp" name="leftFrame" noresize="noresize" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" />
    <frame src="main.asp" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="yes" />
</frameset>
<frame src="bottom.asp" noresize="noresize" frameborder="0" name="bottomFrame" scrolling="no" marginwidth="0" marginheight="0" />
<noframes>
    <body></body>
</noframes>
</frameset>
</HTML>
一登陆他显示请重新登陆!很明显是session("administrator")为空!
作者: 车大炮    时间: 2009-11-19 03:05
原来还有这么多内幕啊,长见识了,呵呵
作者: 波少    时间: 2010-1-14 12:05
情缘采集器站长必备的维护软件,全自动采集,发帖,顶贴,宣传




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2