Can I count online users without using Global. asa?

Source: Internet
Author: User

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]

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.