LoginSignup
1
1

More than 5 years have passed since last update.

RailsでRedisをセッションストアにして、SecureCookieを使う

Last updated at Posted at 2018-01-23

config/initializers/session_store.rb
に以下のような記述を行う。

development では非Secure
production ではSecureとなる。

# Be sure to restart your server when you modify this file.

#Rails.application.config.session_store :cookie_store, key: 'session'

session_key = '_my_application_session'
expires_in = 1.day
redis_server = {
  host: 'localhost',
  port: 6379,
  db: 0,
  namespace: 'session'
}

Rails.application.config.session_store(
  :redis_store,
  key: session_key,
  expires_in: expires_in,
  servers: redis_server,
  secure: Rails.env.production?
)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1