截取网上资料:
1、
----------------------------------------------------------------------------
<Script LANGUAGE = VBScript RUNAT = Server>
Sub Session_OnStart
set rs1=conn.execute("select * from online where oname='"&name&"'")
if rs1.eof and rs1.bof then '如果为空,则说明该用户没有登陆,插入该用户名和当前时间
Conn.Execute("Insert into online(oname,odata,SessionID) Values('"&request("admin")&"','"&Cstr(cdate(now()))&"'," & Session.SessionID & ")")
End Sub
Sub Session_OnStart
Response.Expires = -100
Server.ScriptTimeout = 10
Session.Timeout = 5
End Sub
Sub Session_OnEnd
SET sqlConn = SERVER.CREATEOBJECT("ADODB.Connection")
sqlConn.Open "Provider=sqloledb;Data Source=192.168.0.3;Initial Catalog=;User Id=sa;Password=;"
sSQL = "DELETE From online WHERE SessionID = " & Session.SessionID
SQLConn.Execute(sSQL)
sqlConn.Close
Set sqlConn = Nothing
End Sub
</Script>
------------------------------------------------------------------------
2、
-----------------------------------------------------------------------
Sub Session_OnEnd()
Application.Lock
Application("CurrentUsers")=Application("CurrentUsers")-1
Application.UnLock
set con=server.CreateObject("adodb.connection")
' comm="DRIVER={SQL Server};SERVER=(local);UID=psforumadm;PASSWORD=pabx&*(;DATABASE=psforum"
'Con.Open comm
con.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db1.mdb")
UserName = Session("UserName")
sql="select * from Online where NickName='"&UserName&"'"
set rs=Server.CreateObject ("AdoDb.RecordSet")
rs.Open sql, con, 2, 3
If NOT(rs.Eof or rs.Bof )Then
rs.Delete
rs.UpDate
End If
rs.Close
con.close
If Application("Stats").Exists(Session.SessionID) then
Application.Lock
Application("Stats").Remove(Session.SessionID)
Application.Unlock
end if
end sub
在session_onend()过程里面不能用sever.mappath,改成绝对路径,等到session.timeout之后再看看,应该能行了 在msdn帮助里看到,在Session_OnEnd 事件里不能调用mapmath过程
application("path")=server.mappath("aa.mdb")
在application的start事件上加上这么一句就好了
------------------------------------------------------------------------------
3、
---------------------------------------------------------------------------
<Script LANGUAGE = VBScript RUNAT = Server>
1、
----------------------------------------------------------------------------
<Script LANGUAGE = VBScript RUNAT = Server>
Sub Session_OnStart
set rs1=conn.execute("select * from online where oname='"&name&"'")
if rs1.eof and rs1.bof then '如果为空,则说明该用户没有登陆,插入该用户名和当前时间
Conn.Execute("Insert into online(oname,odata,SessionID) Values('"&request("admin")&"','"&Cstr(cdate(now()))&"'," & Session.SessionID & ")")
End Sub
Sub Session_OnStart
Response.Expires = -100
Server.ScriptTimeout = 10
Session.Timeout = 5
End Sub
Sub Session_OnEnd
SET sqlConn = SERVER.CREATEOBJECT("ADODB.Connection")
sqlConn.Open "Provider=sqloledb;Data Source=192.168.0.3;Initial Catalog=;User Id=sa;Password=;"
sSQL = "DELETE From online WHERE SessionID = " & Session.SessionID
SQLConn.Execute(sSQL)
sqlConn.Close
Set sqlConn = Nothing
End Sub
</Script>
------------------------------------------------------------------------
2、
-----------------------------------------------------------------------
Sub Session_OnEnd()
Application.Lock
Application("CurrentUsers")=Application("CurrentUsers")-1
Application.UnLock
set con=server.CreateObject("adodb.connection")
' comm="DRIVER={SQL Server};SERVER=(local);UID=psforumadm;PASSWORD=pabx&*(;DATABASE=psforum"
'Con.Open comm
con.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("db1.mdb")
UserName = Session("UserName")
sql="select * from Online where NickName='"&UserName&"'"
set rs=Server.CreateObject ("AdoDb.RecordSet")
rs.Open sql, con, 2, 3
If NOT(rs.Eof or rs.Bof )Then
rs.Delete
rs.UpDate
End If
rs.Close
con.close
If Application("Stats").Exists(Session.SessionID) then
Application.Lock
Application("Stats").Remove(Session.SessionID)
Application.Unlock
end if
end sub
在session_onend()过程里面不能用sever.mappath,改成绝对路径,等到session.timeout之后再看看,应该能行了 在msdn帮助里看到,在Session_OnEnd 事件里不能调用mapmath过程
application("path")=server.mappath("aa.mdb")
在application的start事件上加上这么一句就好了
------------------------------------------------------------------------------
3、
---------------------------------------------------------------------------