http cookie 和嵌入图像
我在带有嵌入图像的 .html 页面的 http GET 请求期间设置了一个 cookie。我期望浏览器在获取所有嵌入图像时返回 cookie,但显然第一个嵌入图像不会发生这种情况。
这是它应该如何工作还是我错过了什么?
I'm setting a cookie during http GET request of the .html pages with embedded images. I'm expecting the browser to return the cookies when getting all the embedded images, but apparently it does not happen for the first embedded image.
Is this how it's supposed to work or am I missing something ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保域名与您的域匹配,并且您已为其设置有效的到期日期/时间。这是两个最常见的错误。
Make sure the domain name matches your domain and that you've set a valid expiration date/time for it. These are the 2 most common mistakes.
如果我们知道您如何设置 cookie,将会有所帮助。请注意,NRNR 的响应有点误导 - 他/她对域名的看法是正确的,但没有要求设置过期时间。但是,除非您也显式设置路径,否则您将得到不同的结果 - 即使它只是“/”。
浏览器在处理各种事物(包括 cookie)的方式上确实存在很大差异 - 因此,如果有浏览器在处理引用 html 页面的响应标头之前开始检索附加内容,我不会感到太惊讶。但这不是它应该如何工作的。
C.
It would help if we knew how you were setting the cookies. Note that NRNR's response is a bit misleading - he/she's right about the domain, but there's no requirement to set an expiration. However you will get varying results unless you explicitly set a path too - even if it's just '/'.
Browsers do vary a lot in how they handle all sorts of things, including cookies - so I wouldn't be too surprised if there are browsers out there which start retrieving additional content before the response headers for the referencing html page are processed. This is not how its supposed to work though.
C.