VB icon

Unique Hit Counter

Email
Submitted on: 1/5/2015 12:21:00 PM
By: atwinda (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: ASP (Active Server Pages)
Views: 449
 
     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
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :Unique Hit Counter
'**************************************
2001  Atwinda Software
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: 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
' By: atwinda (from psc cd)
'**************************************

<% '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
%>


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.