Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Share session between subdomains? #108

manuelmeurer opened this Issue · 16 comments

8 participants


Is it possible to share session data between subdomains?
I am trying to set a session cookie on and access it on but it won't work.
I tried using the domain parameter, which is used in the :cookie_store, with the values and :all but to no avail.


this code works for me:

Mainpeople::Application.configure do
  config.session_store :redis_store, redis_server: Settings.redis.url, domain: '.'+Settings.base_host.gsub(/:.*/, '')

Any updates on this?


This works for me for sharing sessions across Heroku domains:

use Rack::Session::Cookie, :key => 'rack.session', :secret => "123", :domain => ""

And In the other application the same line.


You are using rack.session instead of redis_store?


As I know, there was a bug in ActionPack, try with this:


Hmmm, the patch does not support 3.2.11. I'll change:

s.add_dependency 'actionpack', '3.2.8


s.add_dependency 'actionpack', '3.2.11

Hope it doesn't break anything


Update. Still the same issue. That patch doesn't solve anything...


Have you checked the diff between 3.2.8 to 3.2.11? Maybe that monkey-patch isn't valid anymore. I created it while working on a Rails 3.2.6 app at that time.


redis_store does not play well with :domain => :all or any other :domain settings...

I checked again with the traditional :cookie_store, :domain => :all works like a breeze. Wish redis_store could do that just as well


Any news on this?


@jodosha I think we just need to do this:

module Rack
  module Session
    class Redis < ActionDispatch::Session::AbstractStore
@sarmiena sarmiena referenced this issue from a commit in sarmiena/redis-store
@sarmiena sarmiena fixes #108 share between sessions in rails 3.2.11 a040a98

The problem is that the options aren't getting pushed up to rack's cookie options because of how one would assume they should be set. Redis Rack takes the options here.

One would probably write the options like this:

{ :redis_server => {:namespace => 'test:rack:session', domain => ''}

It might look like calling super would push the options given up to rack's initialize method but it's not since they're contained within the redis_server key so rack ignores them.

If written like this however:

{ :redis_server => {:namespace => 'test:rack:session'}, :domain => ''})

The domain '' does get pushed up to Rack's options. Note: I'm using because it was the quickest way to verify. When trying to use pow with a *.dev domain I couldn't seem to get the naming right and sessions would just fail completely.

Ultimately, there needs to be better documentation for how redis server and cookie options are set. I feel that half the pull requests right now are due to options not correctly getting applied and it takes a solid few hours for one to re-learn the redis-store codebase, understand what's happening and realize that it's just an undocumented configuration issue.


@ScotterC would you please open a PR with the fix? Appreciate it, thanks! :tophat:


@jodosha Sure. Do you feel that a documentation update is sufficent or simplifying how the options get passed to Rack vs Redis?

@jodosha jodosha closed this

Should this be working in the latest version now that everything has been extracted out to separate gems? Because it doesn't seem to be working for me in redis-rails.


@Soliah If you're using Rails, you can use my fork which I've had in production for the last year. It simply forces the inheritance of ActionDispatch so that the options are correct.

You can still use the rest of redis-store like this:

gem "redis-rails",                  '~> 4.0' 
gem "redis-rack",                   github: "ScotterC/redis-rack", branch: 'rails-cookie-options'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.