Online demographics can also be achieved without Global.asa

Source: Internet
Author: User
Tags count
Statistics | online | Number online people do not use Global.asa to achieve online statistics

<%
SessionID = Session. SessionID
Timeout = 5
' Set the time to keep session, you can add this value
conn_string = "Driver={microsoft Access DRIVER (*.mdb)};D bq=" & Server.MapPath ("Count.mdb")
' conn_string = ' activeuser '
' Setting up your DSN = ' activeuser ' is a great way to do it because you need to include this file in all ASP scripts


Set conncount =server.createobject ("ADODB.") Connection ")
Conncount.open conn_string

' Delete session after timeout
AAA = DATEADD ("n",-timeout, Now ())
Conncount.execute ("Delete * from Count where Postdate < #" & AAA & "#")


' Keep SESSIONID
sql0 = "Select Sess from Count where sess= '" & 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

' Compute SessionID
SQL2 = "SELECT count (sess) from Count"
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
%>

<%=count%> Active Users




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.