There is a Multitenant App, that should serve sites on domains like
this:
client1.app.com
client2.app.com
And it''s easy to share cookies between all of them (using
''.app.com''
cookie domain):
ActionController::Base.session = {:key => thekey, :secret =>
thesecret, :domain => ''.app.com''}
But! There is one more requirement, those sites should be also avaliable
as:
www.client1.com
So, in order to all this works the App should dynamically change the
cookie domain:
xxx.app.com => ".app.com"
www.xxx.com => ".xxx.com" or leave it blank
Google told me that there is one approach
http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/
but it doesn''t works (Rails 2.3.5).
I also tried my own solution:
class CrossDomainCookies
def initialize(app)
@app = app
end
def call(env)
host =
env["HTTP_HOST"].split('':'').first.downcase
if host.include?(''.'')
normalized_host = host.scan(/[^\.]+\.[^\.]+$/).first
cookie_domain = ".#{normalized_host}"
else
normalized_host = host
cookie_domain = host
end
Rails.logger.info cookie_domain
ActionController::Base.session_options[''domain''] =
cookie_domain
@app.call(env)
end
end
But it also doesn''t works, maybe there are some other solutions?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.