是否有可能删除子饼干? [英] Is it possible to delete subdomain cookies?

查看:109
本文介绍了是否有可能删除子饼干?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有一个子域,metric.foo.com设置一个cookie,是有我的方式来删除到www.foo.com的请求metric.foo.com饼干吗?浏览器(至少火狐)似乎忽略了一个Set-Cookie与metric.foo.com的域。

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.

推荐答案

Cookie是只能由创建它们的域名易读,所以如果cookie在metric.foo.com创建的,它会在同样被删除域,因为它是创建。这包括子域。

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.

如果您需要删除metric.foo.com一个cookie,但目前www.foo.com运行的页面,你就不能。

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.

在为了做到这一点,你需要从metric.foo.com加载页面,或创建下foo.com cookie的,因此它可以是任何的子域下accessable。或使用本:

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时)。域=.foo.com

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

...创建的同时,你之前删除它。

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

..未经测试 - 应该工作

..untested - should work.

这篇关于是否有可能删除子饼干?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆