sessionの有効期限について
使用ツール
Rails 5.1.5
devise 4.4.1
概要
sessionが切れる時の対処法
- config/initializers/devise.rb
config.timeout_inの時間を任意の時間に変更
before
# ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes
after
# ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. config.timeout_in = 1.month
- config/initializers/session_store.rb
expire_afterを任意の時間で設定する
before
Rails.application.config.session_store :active_record_store, :key => '_app_session'
after
Rails.application.config.session_store :active_record_store, :key => '_app_session', :expire_after => 1.month