I'm having trouble verifying the cookie that I leave on a client's computer.
Here is the code:
<%
Dim sPath, filesys, count, getValue, update, twohrs
sPath = Request.ServerVariables("Path_Translated")
sPath = Left(sPath,InStrRev(sPath,"\")) & "counter.txt"
Set filesys = CreateObject("Scripting.FileSystemObject")
Set getValue = filesys.OpenTextFile(sPath,1,0)
' get the current value
count = getValue.ReadLine
If Request.Cookies("hpd")("user") <> "rvisitor" or
Request.Cookies("hpd")("user") <> "admin" Then
' increment by 1 before displaying, 'cos they're a newbie
count = Int(count) + 1
getValue.Close
' overwrite old text file with new one
Set update = filesys.CreateTextFile(sPath)
' put new value in text file
update.WriteLine(count)
update.Close
' give them a cookie to make sure it doesn't count them more than once
Response.Cookies("hpd")("user") = "rvisitor"
' make it expire in 2 hours' time
twohrs = DateAdd("h", 2, Now)
Response.Cookies("hpd").Expires = twohrs
End If
%>
I want admin to be on a few computers that do updates to the webpage. That
way they aren't counted every vist. The problem is that it always
overwrites the cookie with a rvisitor even if admin is present. It will
also count rvisitor twice within two hours if the person hits the homepage
twice while their cookie hasn't expired.
TIA,
Zap
|