【问题标题】:Can not write permanent cookies无法写入永久 cookie
【发布时间】:2010-09-23 02:50:13
【问题描述】:

我尝试了 permanent cookies shortcut with Rails 3.0(和 Ruby 1.9.2),但我无法在此哈希中写入。
我尝试使用以下代码:

cookies.permanent[:last_used_expiration_delay] = @snippet.expiration_delay

但是哈希仍然是空的(这里是 YAML 转储):

 --- !map:ActionDispatch::Cookies::PermanentCookieJar {}

基本 cookie 效果很好,因此我可以使用旧语法手动指定过期日期,但我想使用 Rails 3 中很酷的新东西。

有什么办法可以让永久 cookie 正常工作吗?

【问题讨论】:

    标签: ruby-on-rails cookies


    【解决方案1】:

    我找到了我的回复:cookies.permanent 只是用来写的。要阅读,只需查看 cookies 哈希中的键即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      • 2017-06-06
      • 2019-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      相关资源
      最近更新 更多