README.md

December 5, 2022 · View on GitHub

Unique Hit Counter

Description

This code used cookies to count unique hits.

If the user has the cookie, then the hit isn't

counted. If they don't, then the hit is counted,

and they are given a cookie. All you have to do

is use an #include file="nameoffile.asp" and the

correct action is preformed. I made this script

for my host to count unique hits across his

networked sites. This is also my submission to

the asp world of PSC all my expreience is in the

VB world. I hope you guys like it!

Later

~/Andy

More Info

Submitted On
Byatwinda
LevelBeginner
User Rating4.7 (14 globes from 3 users)
CompatibilityASP (Active Server Pages)
CategoryMiscellaneous
WorldASP / VbScript
Archive File

API Declarations

2001 © Atwinda Software

Source Code

<% 'ASP by Atwinda Software
Response.Expires = 0
Dim strNetSite
'This is the only place you have to change the name
'and the name of the file.
strNetSite = "sitename"
If CheckCookie(strNetSite) = "False" Then
	Call CountHit
	Call AddCookie
End If
Function CheckCookie(strCookieName)
If Request.Cookies(strCookieName) = "" Then
	CheckCookie = "False"
Else
	CheckCookie = "True"
End If
End Function
Function AddCookie()
Response.Buffer = True
Response.Cookies(strNetSite) = strNetSite
Response.Cookies(strNetSite).Expires = Date() + 1
End Function
Function CountHit()
On Error Resume Next
Dim objCntFSO, objCntFile, intHits
Set objCntFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCntFile = objCntFSO.OpenTextFile(Server.MapPath(strNetSite & ".cnt"), 1)
intHits = objCntFile.ReadLine
objCntFile.Close
Set objCntFile = Nothing
If intHits = "" Then intHits = 0
intHits = intHits + 1
Set objCntFile = objCntFSO.CreateTextFile(Server.MapPath(strNetSite & ".cnt"), True)
objCntFile.Write intHits
objCntFile.Close
Set objCntFSO = Nothing
Set objCntFile = Nothing
End Function
%>