View Full Version : How to make vistor counter
02-17-2003, 08:13 PM
I want to make a vistor counter in asp language...
02-17-2003, 09:29 PM
Do a search through this forum, theres a lot of good examples using databases & text files.
02-18-2003, 01: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:
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
Set cf = cfs.OpenTextFile(thefile, 2, True)
If Session("counted") <> "1" Then counter = counter + 1
Set cf = Nothing
Set cfs = Nothing
Session("counted") = "1"
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.