简体   繁体   English

Ruby On Rails 中的持久会话

[英]Persistent sessions in Ruby On Rails

I'd like to add something like the "remember me" option into a Rails application and I need to create a persistent session that doesn't expire when the user closes his browser.我想在 Rails 应用程序中添加类似“记住我”选项的内容,我需要创建一个持久的 session,当用户关闭浏览器时它不会过期。 The only solution I found right now is to use a plugin: http://blog.codahale.com/2006/04/08/dynamic-session-expiration-times-with-rails/我现在找到的唯一解决方案是使用插件: http://blog.codahale.com/2006/04/08/dynamic-session-expiration-times-with-rails/

Are there any other (better) solutions?还有其他(更好的)解决方案吗?

Use cookies and set the expiration to a date very far into the future.使用 cookies 并将到期日期设置为非常遥远的未来。

Take a look at how technoweenie's restful authentication does it.看看 technoweenie 的restful authentication是如何做到的。

Particularly line 122 of the generator which allows login from a cookie.特别是生成器的第 122 行,它允许从 cookie 登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM