是否可能获得存储的cookie的路径? [英] Is it possible to get a stored cookie's path?

查看:90
本文介绍了是否可能获得存储的cookie的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题:可以设置Cookie有效的路径,但是也可以从Cookie(PHP中)(读取)此路径?

Quick question: One can set the path where a cookie is valid, but is it also possible to get (read) this path from the cookie (in PHP)?

否则:是否可以扩展一个cookie的时间,而不知道它是什么路径(但保持路径相同)?

Or else: is it possible to extend a cookie's time, without knowing what path it's on (but keeping the path the same)?

推荐答案

由于大多数浏览器仍然使用Netscape的规范(参见缓存版本的 http://wp.netscape.com/newsref/std/cookie_spec.html ),而不是一个在 RFC 2109 RFC 2965 Cookie 请求头字段中的列表元素将只包含名称和值对:

Since most browsers still use Netscape’s specification (see cached version of http://wp.netscape.com/newsref/std/cookie_spec.html) and not the one specified in RFC 2109 or RFC 2965, the list elements in the Cookie request header field will only consist of the name and value pair:


从HTTP服务器请求URL时,浏览器会将URL与所有Cookie匹配,如果任何匹配,所有匹配的Cookie的名称/值对将包含在HTTP请求中。以下是该行的格式:

When requesting a URL from an HTTP server, the browser will match the URL against all cookies and if any of them match, a line containing the name/value pairs of all matching cookies will be included in the HTTP request. Here is the format of that line:

Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ...


只有较新的规格和RFC 2965)允许客户端发送请求中的路径(摘自RFC 2109):

Only the newer specifications (RFC 2109 and RFC 2965) allow the client to send the path within the request (excerpt from RFC 2109):


标题的语法是:

The syntax for the header is:

cookie          =       "Cookie:" cookie-version
                        1*((";" | ",") cookie-value)
cookie-value    =       NAME "=" VALUE [";" path] [";" domain]
cookie-version  =       "$Version" "=" value
NAME            =       attr
VALUE           =       value
path            =       "$Path" "=" value
domain          =       "$Domain" "=" value

[...]
的值path属性必须是来自相应Set-Cookie响应头的Path属性(如果有的话)
的值。否则,
属性应从Cookie请求标头中省略。 [...]

[…] The value for the path attribute must be the value from the Path attribute, if any, of the corresponding Set-Cookie response header. Otherwise the attribute should be omitted from the Cookie request header. […]

这篇关于是否可能获得存储的cookie的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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