I have a Rails-API app. More or less \"out of the box\" but I want to add back cookie-based session store. Here is what I\'ve done:
app/controllers/application_contr
This worked for me in Rails 6.0, application.rb:
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
config.middleware.insert_after(ActionDispatch::Cookies, ActionDispatch::Session::CookieStore)
If you want to set custom key (yes, it has to be set twice):
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, key: '_your_app'
config.middleware.insert_after(ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, key: '_your_app')
And lastly, if you want to add expiration date - it's done here:
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, key: '_your_app', expire_after: 20.years
config.middleware.insert_after(ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, key: '_your_app')
Would have loved linking to documentation, but there's none.