Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Delete Cookie being accessed from subdomains

Status
Not open for further replies.

mateobus

Programmer
Aug 20, 2007
28
US
Hello,

I would like to create a cookie upon login that can be read on two different subdomains. I have achieved this. The problem that I am having is that I am unable to delete the cookie upon logout, as it can still be read even after it is deleted. Here is the code:

At login the cookie is set from a.mydomain.com:
c#
Code:
HttpCookie cookie = new HttpCookie("my_cookie");
cookie.Value = "test";
cookie.Domain = ".mydomain.com";
Response.Cookies.Add(cookie);

Cookie reading on subdomain (y.x.mydomain.com) vbscript
Code:
myVal = Request.Cookies("my_cookie")

Happens back at a.mydomain.com
Logout:
Code:
Request.Cookies["my_cookie"].Domain = ".mydomain.com";
Request.Cookies["my_cookie"].Expires = DateTime.MinValue;

However when I go back to y.x.mydomain.com, the cookie value still show up as what it was initially set to.

Can anyone shed some light onto why I can't seem to be able to delete the cookie.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top