ASP Design website online Headcount Statistics program

Source: Internet
Author: User
Tags count root directory
Program | design | statistics | online | When browsing the Web, you can often see a number of online numbers of people on the current site who are xxx. How to use ASP to do one? First of all, the analysis of its practice, in general, these online statistics refers to the number of visitors in a period of time statistics. For example (within 5 minutes, 10 minutes) and the length of this time is set by the designer.

Total number of visitors with different IP in this time period, we can draw the current number of online, but there is a precise problem to be solved, as to how to accurately statistics, that is, the different ways of doing things, such as the use of automatically submitted pages, a period of time to read cookies and so on, And in the ASP, there is a better technique, is to use the session object to statistics, here to introduce the Gobal.asa this file, this is a very important document, please look at its structure.


When a session occurs (the user browses the web and makes a request to the Web server) then, if the first user after the server starts, both the Application_onstard and Session_OnStart events occur, and then the If another user makes a request, it only occurs Session_OnStart this event, and the lifetime of the session is how long, can be set, session.timeout=x (minutes)

Well, with this very good method, we can accurately count the number of people online, and the total number is saved with a application variable, when the first session starts at Application_ A statement that empties the counter in the Onstard event application ("online") = 0, and then, in the Session_OnStart event, place a statement to increase the number of people online application ("online") = Application ("online") +1, and in the Session_OnEnd event to put a reduction in the number of online statements, so that the count value minus one.

In this way, the document is replaced by the following


Next, make up a program that displays graphic numbers, displaying the number of people online on the specified page. So we can get the numbers.

*online.asp

<% @language = "VBScript"%>
<%
Tmp=application ("online")
TMP=CSTR (TMP)
Dim disp (20)
Dim images (20)
Dbbits=len (TMP)
For i= 1 to Dbbits
Disp (I) =left (Right (tmp,i), I-(I-1))
Next

For I=dbbits to 1 step-1
Images (i) = ""

Response.Write "Document.Write (" &images (I) & ");"

Next

%>


The above procedure is very simple, here does not make the analysis, invites everybody to read by oneself. Use a script statement to refer to the Online.asp file on the page that invokes the online statistics to display the graphical statistics device.


Now it's OK, remember the gist, you have to put Gobal.asa on the right Web application root directory, and it is best to create a new Web application for this statistic alone, not to mess with other programs, otherwise the data is inaccurate, and it is easy to modify the program to multi-user online statistics. This can provide online statistical services, how to achieve please let us think about it ....

Related Article

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.