您能否仅为domain.tld和www.domain.tld设置cookie? [英] Can you set a cookie only for domain.tld and www.domain.tld?

查看:73
本文介绍了您能否仅为domain.tld和www.domain.tld设置cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能否仅为domain.tld和www.domain.tld设置cookie,以便如果您转到任何其他子域(例如bla.doamin.tld),将不会设置cookie?

Can you set a cookie only for domain.tld and www.domain.tld so that if you go to any other subdomain (bla.doamin.tld for example) the cookie won't be set?

推荐答案

您可以执行此操作。此Cookie规范中提到了它: http://curl.haxx.se/rfc/cookie_spec.html

You can do this. It's mentioned in this cookie spec: http://curl.haxx.se/rfc/cookie_spec.html


在cookie列表中搜索有效的cookie时,将cookie的域属性与Internet域进行比较将从其获取URL的主机的名称。如果存在尾部匹配,则cookie将通过路径匹配来查看是否应发送。 尾部匹配是指将域属性与主机的完全限定域名的尾部匹配。域属性 acme.com将匹配主机名 anvil.acme.com以及 shipping.crate.acme.com。

When searching the cookie list for valid cookies, a comparison of the domain attributes of the cookie is made with the Internet domain name of the host from which the URL will be fetched. If there is a tail match, then the cookie will go through path matching to see if it should be sent. "Tail matching" means that domain attribute is matched against the tail of the fully qualified domain name of the host. A domain attribute of "acme.com" would match host names "anvil.acme.com" as well as "shipping.crate.acme.com".

这篇关于您能否仅为domain.tld和www.domain.tld设置cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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