我为我的 Rails 应用程序 (Rails 2) 使用插件 authlogic。 如何通过 authlogic 将数据保存在 session 中?够安全吗?
比如我在里面保存session[:group_id] = 1
,它会保存在客户端PC的cookie里吗?如果是,我如何更改 session 设置,以便将其保存在服务器端而不是客户端?
您是否有任何提示,我如何以安全的方式保存数据,在不使用 cookie 的情况下在多次请求后仍然存在?
最佳答案
您可以选择在您的应用程序中存储 session 的位置:
- CookieStore - 将所有内容存储在客户端上。
- DRBStore - 将数据存储在 DRb 客户端上。
- MemCacheStore - 将数据存储在 MemCache 中。
- ActiveRecordStore - 使用 ActiveRecord 将数据存储在数据库中。
在 config/environment.rb
文件中:
# Set to one of [:active_record_store, :drb_store, :mem_cache_store, :cookie_store]
config.action_controller.session_store = :active_record_store
还有一个关于使用 session 安全性的官方指南http://guides.rubyonrails.org/security.html#sessions
关于ruby-on-rails - authlogic如何保存 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6698284/