Rails 中的会话管理 (2.3)
显然,升级到 Rails 2.3 后,我的会话存储已停止工作。我曾经有过这个:
session :session_expires => 3.years.from_now
在我的 application_controller.rb 中,但现在每次我关闭浏览器(chrome)时会话都会过期。我从某处读到 session_expires 会更改为 expire_after,但是
session :expire_after => 3.years.from_now
也没有做任何好事。
Apparently, after upgrading to Rails 2.3 my session storage has stopped working. I used to have this:
session :session_expires => 3.years.from_now
in my application_controller.rb, but now every time i close the browser (chrome) the session expires. I read from somewhere that session_expires would have changed to expire_after, but
session :expire_after => 3.years.from_now
didn't do any good eihter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,不知道为什么“session :expire_after => ...”不起作用,但我让它与此一起工作:
ActionController::Base.session_options[:expire_after] = 3.years
Ok, don't know why "session :expire_after => ..." didn't work, but i got it working with this:
ActionController::Base.session_options[:expire_after] = 3.years
将其放入您的 ApplicationController 中,当您的会话到期时,将生成一个新的会话。
Place this into your ApplicationController and just as your session expires a new one will be generated.