Checking if a cookie has already been set

Discussion in 'ASP General' started by Andrew Duffy, Oct 10, 2003.

  1. Andrew Duffy

    Andrew Duffy Guest

    Hi,

    I just want to check that i'm not going crazy.. I want to check
    whether or not a cookie has already been set and so I am using the
    following code.

    cookieValue = Request.Cookies("CartID")
    'if cookie hasn't already been set, then set it!
    If cookieValue = "" Then

    Response.Cookies("CartID") = "3"
    Response.Cookies("CartID").Expires = "Jan 1, 2005"

    End if

    I have also used IsNull yet both just don't seem to work.... am I
    missing something here?

    Thanks heaps
    Andrew Duffy
     
    Andrew Duffy, Oct 10, 2003
    #1
    1. Advertisements

  2. Andrew Duffy

    Ray at Guest

    What do you mean they don't work? What does this do?

    cookieValue = Request.Cookies("CartID")

    <%
    Response.Write "cookieValue = """": " & (cookieValue = "") & "<br>"
    Response.Write "IsNull(cookieValue): " & IsNull(cookieValue) & "<br>"
    Response.Write "So, then, the value is " & cookieValue
    %>

    Ray at home
     
    Ray at, Oct 10, 2003
    #2
    1. Advertisements

  3. Andrew Duffy

    Ray at Guest

    Yeah, perhaps I should have put the first line in the script block too...
    Oops.

    Ray at home
     
    Ray at, Oct 10, 2003
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.