gpt4 book ai didi

ruby-on-rails - rails : read cookie set date

转载 作者:行者123 更新时间:2023-12-04 06:55:36 28 4
gpt4 key购买 nike

如何读取 cookie 设置日期?
rails api我找不到这个信息,谷歌也没有...

最佳答案

你不能。
以下是 cookie 的工作原理:

客户端请求一个文档,并在响应中收到:

  Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT

当客户端请求此服务器上路径“/”中的 URL 时,它会发送:
  Cookie: CUSTOMER=WILE_E_COYOTE

想法是浏览器管理它是否应该将cookie发送回服务器。
Web 服务器不会被告知 cookie 的到期日期。

稍后编辑 : Wikipedia更准确地说:

Cookies expire, and are therefore not sent by the browser to the server, under any of these conditions:

  1. At the end of the user session (i.e. when the browser is shut down) if the cookie is not persistent
  2. An expiration date has been specified, and has passed
  3. The expiration date of the cookie is changed (by the server or the script) to a date in the past
  4. The browser deletes the cookie by user request

The third condition allows a server or script to explicitly delete a cookie. Note that the browser doesn't send to the server information about cookie lifetime, so there is no way for the server to check if the cookie expires soon.

关于ruby-on-rails - rails : read cookie set date,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2606318/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com