With Rails and Devise, how to set cookie properties if I use ActiveRecord storage?

In myapp/config/initializers/session_store.rb , I have the following:

 Myapp::Application.config.session_store :cookie_store, :key => '_myapp_session', :domain => :all 

The :key option specifies the name for the cookie, and :domain => :all says that the cookie can be used for common subdomains.

Now I want to move on to using ActiveRecord to store the session. If I do this:

 Myapp::Application.config.session_store :active_record_store 

... although the session is stored in the database, there is still, of course, a cookie. But I no longer control his name or region.

How can I use ActiveRecord storage for a session and still specify a cookie name and domain?

+6
source share
1 answer

Calculated

It is very simple, actually:

 Myapp::Application.config.session_store :active_record_store, :key => '_myapp_session', :domain => :all 
+8
source

Source: https://habr.com/ru/post/892148/


All Articles