Checking if a cookie has already been set

A

Andrew Duffy

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
 
R

Ray at

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
 
R

Ray at

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

Ray at home
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top