Can I count online users without using Global. asa?
<%
SessionID = session. SessionID
Timeout = 5
'Set the session persistence time.
Conn_String = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =" & Server. MapPath ("count. mdb ")
'Conn _ String = "activeUser"
'It is best to set DSN = "activeuser" because we need to include this file in all ASP scripts.
Set ConnCount = Server. CreateObject ("ADODB. Connection ")
ConnCount. Open Conn_String
Aaa = dateadd ("n",-timeout, now ())
ConnCount. Execute ("delete * from count where postdate <#" & aaa &"#")
'Delete the session after timeout.
Sql0 = "select sess from count where sess = '" & sessionID &"'"
'Keep sessionID.
Set rscheck = connCount. Execute (sql0)
If rscheck. eof then
SQL = "insert into count (sess, postdate) values ('" & sessionID & "', '" & now ()&"')"
ConnCount. Execute (SQL)
End if
Rscheck. close
Set rscheck = nothing
Sql2 = "select count (sess) from count"
'Calculates the sessionID.
Set rs = connCount. Execute (sql2)
Count = rs (0)
Rs. close
Set rs = nothing
Sql3 = "select * from count"
Set rspredel = connCount. Execute (sql3)
Do until rspredel. eof
Xxx = DateDiff ("n", rspredel ("postdate"), Now ())
If xxx> timeout then
Count = count-1
End if
Rspredel. movenext
Loop
Rspredel. close
Set rspredel = nothing
ConnCount. Close
Set connCount = nothing
If count = 0 then
Count = 1
End if
%>
There are currently <%= count %> people dancing with the wind and lingering!
[1]