views:

57

answers:

2

Updated question to make it more clear

I understand that you can set the domain of your session_store to share sessions between subdomains like this: Rails.application.config.session_store :cookie_store, :key => '_my_key', :domain => "mydomain.com"

in Rails 3, what does the setting :domain => :all do? It can't let you share sessions across top-level domains, cookies can't do that. The documentation says it assumes one top level domain. So what happens if multiple domains access your app?

In my app, my users can create personal subdomains of one main domain, but then can also access that subdomain via their own custom domain.

What is the correct session_store domain setting so that I can: a) share sessions across all domains of my primary domain, eg "mydomain.com" b) users who access their personal subdomain eg "user1.mydomain.com" via a CNAME custom url like "some.otherdomain.com" can still create separate sessions.

Thanks

A: 

This option is used to make sure the application will be able to share sessions across subdomains. The :all option assumes that our application has a top-level domain size of 1. If not then we can specify a domain name instead and that will be used as the base domain for the session.

Rishav Rastogi
Rishav: when I specify a domain like 'mydomain.com' that works for all subdomains, but if a user comes into the app via a custom domain it doesn't seem to create a session using :all. What's the correct way to handle that?
Nader
As I said, domain => :all assumes 1 top-level domain. In your case is it like "foo.com" and "bar.com" .. come to same instance of your rails ? and you want share sessions b/w the domains ?
Rishav Rastogi
In my app each user has a subdomain of foo.com Some users also ave custom domains like bar.com pointing at their foo.com subdomain So yes ideally I'd share sessions between all domains, but that is not critical, as long as sessions at least are shared between each top level domain.
Nader
i updated the question to make it more clear
Nader