Good Day Folks,
Setting the domain attribute when creating a cookie, see code below, seems
to create a problem that I can't expire the cookie later, see 2nd code block.
If I don't set the domain attribute, then expiring the cookie works as
expected. Unfortunately I need to set the domain attribute because the
cookie needs to exist accross multiple servers. Any ideas on how to expire a
cookie which was created using the following code. Thanks in advance. Serge.
' Create cookie
Response.cookies("Cookietest")("p_userid")="jdoe"
Response.cookies("Cookietest")("p_password")="test"
Response.cookies("Cookietest").domain="ocdsb.ca"
' Expire/delete cookie.
Dim aCookie As HttpCookie
aCookie = Request.Cookies("Cookietest")
aCookie.Expires = DateTime.Now.AddDays(-1)
Response.Cookies.Add(aCookie)
Josh Twist - 25 Apr 2006 19:12 GMT
Hi Serge,
You aren't setting the domain of the cookie you're deleting...
' Expire/delete cookie.
Dim aCookie As HttpCookie
aCookie = Request.Cookies("Cookietest")
aCookie.Expires = DateTime.Now.AddDays(-1)
aCookie.Domain = "ocdsb.ca"
Response.Cookies.Add(aCookie)
My blog post on using ieHttpHeaders talks about this very problem -
might interest you:
http://www.thejoyofcode.com/Better_understand_Cookies_with_ieHTTPHeaders.aspx
Josh
http://www.thejoyofcode.com/