Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Verify cookies

Thread Tools

Verify cookies

Posts: n/a
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

' overwrite old text file with new one
Set update = filesys.CreateTextFile(sPath)

' put new value in text file

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


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
What's the proper way of reading cookies? Request.Cookies("mycook") doesnt work user ASP .Net 3 03-31-2007 01:53 PM
Response.Cookies vs Request.Cookies Alex Nitulescu ASP .Net 1 02-03-2005 09:43 AM
Persistent Cookies vs. session cookies Andy Fish Java 3 11-06-2003 10:44 AM
Good Cookies bad Cookies? AK Computer Support 23 10-26-2003 05:20 AM