【问题标题】:Google App Engine Set-Cookie fails to use my expiration dateGoogle App Engine Set-Cookie 未能使用我的到期日期
【发布时间】:2010-09-09 23:59:53
【问题描述】:

我正在尝试在我的 Google App Engine 页面中设置 cookie:

self.response.headers.add_header('Set-Cookie','CookieName=1234; expires:Sun, 31-May-2009 23:59:59 GMT; path=/;')

到期日期未显示在浏览器中。因此,它会在会话结束时自行删除。

这是 curl -D 的输出:

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Set-Cookie: CookieName=1234; expires:Fri, 01 Jan 2010 11:48:41 GMT
Date: Fri, 08 May 2009 11:57:25 GMT
Server: Google Frontend
Expires: Fri, 08 May 2009 11:57:25 GMT
Transfer-Encoding: chunked

我错过了什么?

【问题讨论】:

    标签: google-app-engine cookies


    【解决方案1】:

    问题是您使用带有冒号的“expires:”。需要是 "expires=" 和等号。

    【讨论】:

    • 完美!这解决了问题。
    • 这些是您可以盯着看几个小时而错过的问题。当这种情况发生时,我讨厌它。很高兴为您提供帮助!
    • 对于那些(显然)讨厌走捷径的开发者来说,完美使用 StackOverflow :)
    【解决方案2】:

    通过“curl -D somefile”,我可以检查您的 cookie 是否完全按照指定的方式到达客户端。您能检查一下,并确认问题出在您的浏览器及其设置上,而不是服务器端吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-22
      • 1970-01-01
      • 2012-11-14
      • 2016-05-19
      • 2014-01-06
      • 1970-01-01
      相关资源
      最近更新 更多