Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to delete subdomain cookies?

If there is a cookie set for a subdomain, metric.foo.com, is there a way for me to delete the metric.foo.com cookie on a request to www.foo.com? The browser (at least Firefox) seems to ignore a Set-Cookie with a domain of metric.foo.com.

like image 453
dan-manges Avatar asked Sep 22 '08 20:09

dan-manges


People also ask

How do I delete a subdomain cookie?

The only workaround that selectively deletes cookies for a specific subdomain is to go to Edit→Settings→Privacy & Security→Cookies and Site Data→Manage Exceptions and add an exception for https://badcookies.myorg.com to make it Allow for Session .

Do subdomains have access to cookies?

That is, if the domain name in your cookie's domain parameter doesn't start with a period, then it will not let subdomains read that cookie. If it does start with the period, then all subdomains will have full access to that cookie's value. Can only be read by example.com.

Is a subdomain a third party cookie?

Conclusion: if a resource sets a cookie and the base domain on the resource is the same as the base domain on the web site, but the subdomain is different, popular browsers do not treat it as a third-party cookie.


1 Answers

Cookies are only readable by the domain that created them, so if the cookie was created at metric.foo.com, it will have to be deleted under the same domain as it was created. This includes sub-domains.

If you are required to delete a cookie from metric.foo.com, but are currently running a page at www.foo.com, you will not be able to.

In order to do this, you need to load the page from metric.foo.com, or create the cookie under foo.com so it can be accessable under any subdomain. OR use this:

Response.cookies("mycookie").domain = ".foo.com"

...while creating it, AND before you delete it.

..untested - should work.

like image 170
Kolten Avatar answered Oct 01 '22 03:10

Kolten