Use the database for sessions instead of the cookie-based default, which shouldn't be used to store highly confidential information
Create the session table with
Run the migration
Make sure you also tell rails to use ActiveRecord to manage your sessions too.
Rails 2
config/environment.rb:
Rails 3
config/initializers/session_store.rb:
Create the session table with
1.rake db:sessions:create
Run the migration
rake db:migrate
Make sure you also tell rails to use ActiveRecord to manage your sessions too.
Rails 2
config/environment.rb:
config.action_controller.session_store = :active_record_store
Rails 3
config/initializers/session_store.rb:
Rails.application.config.session_store :active_record_store
本文介绍了一种改进的会话管理方式,建议使用数据库来存储会话信息而非默认的Cookie方式,尤其对于包含敏感信息的情况更为适用。文章提供了具体的配置步骤和技术细节,包括创建会话表、运行迁移以及配置Rails应用程序来使用ActiveRecord进行会话管理。
246

被折叠的 条评论
为什么被折叠?



