Counter
This is a more accurate counter than our previous
example , in this example the count only gets incremented once
per session . This means your count will be more accurate if
you want it to be that is. create a txt file and put your starting
number in it . Then copy this code where you want the counter
to display. In the example below the counter3.txt is placed
in the same directory as this page , if you put the txt file
elsewhere remember and alter the Server.MapPath part of the
code.
Visitor number
<%
'create a FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'this is the path to our counter file
CounterFile = Server.MapPath("counter3.txt")
Set objCount = objFSO.OpenTextFile(CounterFile)
visitorcount = CLng(objCount.ReadLine)
if Session("visitorcount") = "" then
Session("visitorcount") = visitorcount
visitorcount = visitorcount + 1
objCount.close
Set objCount = objFSO.CreateTextFile("counter3.txt",
True)
objCount.WriteLine(visitorcount)
end if
objCount.Close
'display count
Response.Write visitorcount
%>