Can I count online users without using Global. asa?

Source: Internet
Author: User

NoGlobal. asaCan the number of online users be counted?

<%
SessionID = session. SessionID
Timeout = 5
'SetSessionRetention Time.

Conn_String = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =" & Server. MapPath ("count. mdb ")
'Conn _ String = "activeUser"
'Best settingDSN = "activeuser ",Because we needASPThe script contains this file..

Set ConnCount = Server. CreateObject ("ADODB. Connection ")
ConnCount. Open Conn_String

Aaa = dateadd ("n",-timeout, now ())
ConnCount. Execute ("delete * from count where postdate <#" & aaa &"#")
'Delete after timeoutSession.

Sql0 = "select sess from count where sess = '" & sessionID &"'"

'PersistenceSessionID.
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"

'ComputingSessionID.
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
%>

Currently<% = Count %>People dance with the wind!

 

[1]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.