Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / April 2006

Tip: Looking for answers? Try searching our database.

Can't expire cookie with domain attribute set.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Serge - 25 Apr 2006 17:48 GMT
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/

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.