子域cookie,在父域请求中发送? [英] sub-domain cookies, sent in a parent domain request?

查看:410
本文介绍了子域cookie,在父域请求中发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否在父域HTTP请求中发送子域Cookie?

Are sub-domain cookies sent in a parent domain HTTP request?

例如,我有Cookie:

For instance, say I have the cookies:

Name     Value     Domain (not https)
ABC      1         .example.com
XYZ      0         foo.example.com
DEF      0         bar.example.com

将发送XYZ@foo.example.com和DEF@bar.example.com在 http://example.com/content 的HTTP标头 cookies 中,和/或 http://QQQ.example.com/content

Would XYZ@foo.example.com and DEF@bar.example.com be sent along in the HTTP-header cookies on a reqeust to http://example.com/content, and/or http://QQQ.example.com/content

推荐答案

域值 .example.com 中的前导点表示 example.com 及其子域。没有前导点,Cookie只对此特定域有效。

The leading dot in the domain value .example.com means example.com and its subdomains. Without the leading dot, the cookie is only valid for this specific domain.

请注意,设置Cookie时,没有前导点的域值将以点为前缀。只有当未设置 domain 参数时,用户代理才会假定该Cookie的当前域。

Note that when setting a cookie, domain values without a leading dot will be prepended with a dot. Only when the domain parameter is not set the user agent assumes the current domain for that cookie.

$ c> http://example.com/ ,则只会发送 .example.com 的Cookie。但是 http://foo.example.com/ 的情况下, .example.com foo.example.com 将被发送。在 http://bla.foo.example.com 的情况下,只有 .example.com 将被发送。

So in this case, if http://example.com/ is requested, only the cookie for .example.com will be sent. But in case of http://foo.example.com/, both cookies for .example.com and foo.example.com will be sent. And in case of http://bla.foo.example.com, only the cookie for .example.com will be sent.

这篇关于子域cookie,在父域请求中发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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