[求助] 为何总说缺少对像?
各位前辈新年好!我作的登录记录,加入限制重复登录的代码后,总是显示:Microsoft VBScript 运行时错误 (0x800A01A8)缺少对象: 'Session(...)',index.asp, 第 37 行,即下列红色一行。想请教各位前辈帮忙看一下,问题在哪里?代码如下:
<%
Response.Expires = 0 'expires属性指定了在浏览器上缓冲存储的页距过期还有多少时间。设置response.expires=0,则使缓存的页面立即过期。
Function checkenter() '判断是否有非法输入
If username<>"" and password<>"" and otherpwd<>"" and Instr(username,"'")<1 and Instr(username," ")<1 and Instr(username,"""")<1 and Instr(username,"&")<1 then
checkenter=TRUE '允许进行用户验证
Else
checkenter=FALSE '不允许进行用户验证
End If
End Function
Function checksysUser() '系统用户验证
sql="SELECT * FROM fdb_man WHERE user='"&username&"'"
Set rs=Server.CreateObject("adodb.recordset")
rs.Open sql,conn,1,1
if rs.eof then
checksysUser=FALSE
Session("passed")=False
else
passwd=trim(rs("pwd"))
if passwd=password then
checksysUser=TRUE
Session("passed")=True
Session("level")=rs("level")
Session("admin")=rs("admin")
else
checksysUser=FALSE
Session("passed")=False
end if
End if
rs.close
conn.close
End Function
Function IsOnline(user)
Dim mysql
mysql ="SELECT * FROM kaoqing_table WHERE user='"&username&"' and recordYear="&Year(Now())&" and recordMonth="&Month(Now())&" and recordDay="&Day(Now())&""
Set objRS = Session("objRS")
objRS.Source = mysql
objRS.Open
If Iswork=0 Then
IsOnline = True
Else
IsOnline = False
End If
objRS.Close
Set objRS = Nothing
End Function
%>
<HTML>
<HEAD>
<TITLE>用户分级登录、有效性验证</TITLE>
<script language="VBScript">
<!--
Sub login_OnClick
Dim msg
msg = ""
If fus.stxm.value = "" Then
msg = "姓名不能为空!请先选择..."
fus.stxm.focus
End If
If msg = "" Then
fus.submit
ElseIf fus.pwd.value = "" Then
msg = "密码不能为空!请先输入..."
fus.stid.focus
ElseIf Len(fus.pwd.value) < 4 Or _
Not IsNumeric(fus.pwd.value) Then
msg = "密码由4位数字组成!请修改..."
fus.pwd.focus
Else
Alert(msg)
End If
End Sub
Sub reset_OnClick
fus.pwd.value = ""
fus.stxm.value = ""
fus.pwd.focus
End Sub
-->
</script>
</HEAD>
<BODY bgColor=#FFFFFF topMargin=0 leftmargin="0" onload="return window_onload()">
<p align="center"><b><font size="6" color="#6699FF">考勤系统欢迎你登录</font></b></p>
<%
if Request.Form("action")="true" then
username=trim(Request.Form("username")) '登录用户名
password=trim(Request.Form("password")) '登录密码
otherpwd = Trim(Request.form("otherpwd")) '附加码
reotherpwd = Trim(Request.form("reotherpwd"))'生成的附加码
legalTag=checkenter()
If legalTag=TRUE then '如果没有非法输入,则进行用户验证
if otherpwd = reotherpwd then '附加码比较
legalUserTag=checksysUser() '系统用户验证
if legalUserTag=true then
If Session("level")=1 and Session("admin")="True" Then
Response.Redirect("manage.asp")
Response.End
End If
If Session("level")=2 Then
Response.Redirect("main.asp")
Response.End
End If
If Session("level")=3 Then
logtoncount=IsOnline(user)
If logtoncount=True Then
set rs=server.createobject("adodb.recordset")
insertsql="select * from kaoqing_table"
rs.open insertsql,db,1,3
rs.addnew
rs("user")=username
rs("recordYear")=Year(Now())
rs("recordMonth")=Month(Now())
rs("recordDay")=Day(Now())
rs("recordTime")=Time
rs("Iswork")=1
rs("note")=note
rs.update
rs.close
set rs=nothing
Response.Redirect("normal.asp")
else
Response.Write"你已登录!"
End If
Response.End
End If
else
errmsg="<font color=#FF0000><b>用户名或者用户密码错误,请重新输入!</b></font>"
end if
else
errmsg="<font color=#FF0000><b>附加码输入错误,请重新输入!</b></font>"
end if
else
errmsg="<font color=#FF0000><b>用户名输入有误,请重新输入!</b></font>"
end if
end if
%>