...

View Full Version : How to make vistor counter



Aymen++
02-17-2003, 07:13 PM
I want to make a vistor counter in asp language...

dagaffer
02-17-2003, 08:29 PM
Do a search through this forum, theres a lot of good examples using databases & text files.

whammy
02-18-2003, 12:37 AM
Here's a very simple one that uses FileSystemObject to write to a text file, that won't be incremented upon refresh (since it uses a session variable). It also creates the text file if it doesn't exist:

http://www.solidscripts.com/displayscript.asp?sid=4



<%
Dim cfs, cf, thefile, counter, sMapPath
sMapPath = Server.MapPath("\")
thefile = Mid(sMapPath, 1, InStrRev(sMapPath,"\")-1) & "\database\counter.txt"
Set cfs = CreateObject("Scripting.FileSystemObject")
If cfs.FileExists(thefile) Then
Set cf = cfs.OpenTextFile(thefile, 1)
counter = cf.ReadLine
End If
Set cf = cfs.OpenTextFile(thefile, 2, True)
If Session("counted") <> "1" Then counter = counter + 1
cf.WriteLine(counter)
Set cf = Nothing
Set cfs = Nothing
Session("counted") = "1"
%>


If you search with some diligence there are many other solutions here as well, I use a counter/logging script with an Access database on my website (I don't display any count on the page though) which keeps track of much more information in an access database (even whether or not users have javascript enabled - although from what I've gathered out of the statistics that really isn't of much use).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum