HTTP Cookie 请求标头事件序列

发布于 2025-01-07 19:40:06 字数 378 浏览 3 评论 0原文

我对使用 cookie 时的事件顺序有点不确定。如果客户端应用程序重复从服务器请求同一页面,我认为会发生以下情况:

  1. 客户端应用程序发出请求,
  2. 服务器端返回一个 Set-Cookie 响应标头,
  3. 客户端发出另一个请求,将步骤 2 中返回的 cookie 放入 HTTP 请求中 服务器端返回“Cookie”标头
  4. ,但响应标头中没有 Set-Cookie

这是正确的顺序吗? (我对步骤 4 特别感兴趣 - 服务器是否返回 Set-Cookie 以响应提供 cookie 的请求)

如果这有什么区别的话,所讨论的 cookie 实际上是 JSESSIONID cookie。

谢谢

戴夫

I am a little uncertain about the sequence of events when using cookies. Here's what I think happens if a client application repeatedly requests the same page from the server:

  1. client application makes a request
  2. server side returns with a Set-Cookie response header
  3. client makes another request, putting the cookie returned in step 2 in to the HTTP request "Cookie" header
  4. server side returns but with no Set-Cookie in the response header

Is that the correct sequence? ( I'm particularly interested in Step 4 - does the server return a Set-Cookie in response to a request that has supplied a cookie )

The cookie in question is actually a JSESSIONID cookie, if that makes any difference.

Thanks

Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故笙诉离歌 2025-01-14 19:40:06

是的,这是正确的顺序。但是,我看到许多应用程序发送回具有相同值的“Set-Cookie”标头。它不会损害流程,因为值是相同的,即使客户端更新 cookie,它仍然是相同的值(因此,相同的会话)。

Yes, that's the correct sequence. However, I've seen many applications sending back "Set-Cookie" header with the same value. It does not harm the flow, since values are the same and even if client updates the cookie it's still the same value (thus, the same session).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文