Verify cookies

Discussion in 'ASP General' started by Zap, Jul 10, 2003.

  1. Zap

    Zap Guest

    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
     
    Zap, Jul 10, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    9,303
    Hans Kesting
    Feb 3, 2005
  2. Andy Fish
    Replies:
    3
    Views:
    6,847
    Fredrik Lindner
    Nov 6, 2003
  3. user
    Replies:
    3
    Views:
    833
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 31, 2007
  4. archana
    Replies:
    1
    Views:
    640
  5. mhshpk
    Replies:
    0
    Views:
    735
    mhshpk
    Jul 18, 2007
  6. Eric
    Replies:
    1
    Views:
    2,316
    Mark Fitzpatrick
    Dec 28, 2007
  7. _Who
    Replies:
    7
    Views:
    3,110
  8. Cal Who

    Response.cookies vs Request.cookies

    Cal Who, Dec 5, 2009, in forum: ASP .Net
    Replies:
    7
    Views:
    1,807
    Gregory A. Beamer
    Dec 10, 2009
Loading...