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 the code snippet below where you want the counter to display on your page.
In the example below the counter.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.
‘create a FileSystemObject
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
‘this is the path to our counter file
CounterFile = Server.MapPath(“counter.txt”)
Set objCount = objFSO.OpenTextFile(CounterFile)
visitorcount = CLng(objCount.ReadLine)
if Session(“visitorcount”) = “” then
Session(“visitorcount”) = visitorcount
visitorcount = visitorcount + 1
Set objCount = objFSO.CreateTextFile(“counter.txt”, True)