Write a "fair" ASP Graphics counter

Source: Internet
Author: User
Tags dsn
"Technical World" in the "Writing ASP Graphics Counter", a detailed description of how to use the popular ASP to write counters. However, the drawback is that if a user repeatedly click the "Refresh" button, then the counter is still to increase, which is unfair to the site click Rate Rating, also lost the counter as a function of normal statistics. How can we avoid this in a technical way?
I think to prevent Internet users continuously press the "refresh" counter also continuously increase the problem, the best way is to take advantage of ASP's session object, we can use the session object to first determine whether the user is a new connector, if it is, then

IsEmpty (Session ("hasbeenconnected")) =true, that is, the session ("hasbeenconnected") is empty. Then, run the program, make the counter 1, and then set the user's session ("Hasbeenconnected") to true, that is, the user is no longer a new connector, no matter how he presses the "refresh" button continuously, the counter will not increase.

Combined with the "Writing ASP Graphics Counter", the last site counter source program should be:

......
<body>
<%dim Tms,counter,countlen
Dim images (20)
h1= "<p><font color= ' #8000ff ' > This is an ASP counter </font></p>"
If IsEmpty (Session ("hasbeenconnected")) Then
Set Rs=server.createobject ("Adodb.recordset")
Application.Lock
Rs.Open "Update aspcount set countss=countss+1", "Dsn=userdbs", 3,3
Application.UnLock
Session ("hasbeenconnected") =true
End If
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Aspcount", "Dsn=userdbs", 3,3
Rs.movefirst
Counter=rs (0)
Countlen=len (counter)
tms= "Response.Write (TMS)
For I=1 to Countlen
Images (i) = "</img>"
Next
Response.Write Images (1) &&images (2) &&images (3) &&images (4) &&images (5) && Images (6) &&images (7)
Rs. Close
%>
</body>


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.