Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Rails and Devise, how do I set the cookie properties if I'm using ActiveRecord store?

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 sets the name to use for the cookie, and :domain => :all says that the cookie can be shared across subdomains.

Now I want to move 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 have control over its name or scope.

How can I use ActiveRecord store for the session and still specify the cookie name and domain?

like image 863
Nathan Long Avatar asked Jul 06 '11 15:07

Nathan Long


1 Answers

Figured it out

It's very simple, actually:

Myapp::Application.config.session_store :active_record_store, :key => '_myapp_session', :domain => :all
like image 190
Nathan Long Avatar answered Sep 20 '22 20:09

Nathan Long