Counter | refresh | page Hello everyone!
Today I want to talk about a Web page counter problem, some Web site counters in the User Refresh page, the value will be added 1, such counters are not sound. If your site is doing some award-winning activities, for example, "If you are the 100,000th user you will get the prizes provided by this site".
So, here's the original code for a counter, and you're going to create a new Counter.txt file under this ASP file that holds the value.
<%
function counts (counterfile)
Dim Objfso,objts
Application.Lock ' Lock Object
Set Objfso=server.createobject ("Scripting.FileSystemObject")
Set Objts=objfso.opentextfile (Server.MapPath (counterfile), 1,true)
If not Objts.atendofstream then ' check to reach end of file
COUNTS=CLNG (Objts.readline)
End If
Counts=counts+1
Objts.close
Set Objts=objfso.opentextfile (Server.MapPath (counterfile), 2,true)
objTS.WriteLine (counts)
Objts.close
Application.UnLock ' unlock
End Function
If session ("Counter") =empty Then
Session ("Counter") =counts ("Counter.txt")
End If
%>
<body>
You are <%=session ("counter")%> Guest
</body>
Such a perfect counter is made.