[Rails] Re: Sharing sessions between subdomains?

softwareengineer 99 softwareengineer99 at yahoo.com
Wed Feb 8 14:33:24 GMT 2006


Hi Zsombor,
  
  Thank you very much for your reply.
  I will test it out right now.
  
  Thanks again.
  Frank

Dee Zsombor <dee.zsombor at gmail.com> wrote:  You need to set the session domain in your production.rb

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(
:session_domain => '.suprglu.com')

For develpment&&testing you should change test.rb, and development.rb:

ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(
:session_domain => '.localhost.com')

then configure your /etc/hosts file to map localhost.com,
something.localhost.com to 127.0.0.1. You now have a subdomained
development setup at your disposal!

For functional tests you would place this into test/test_helper.rb

module ActionController
  class TestRequest
    def with_subdomain(subdomain=nil)
      the_host_name = "localhost.com"
      the_host_name = "#{subdomain}.localhost.com" if subdomain
      self.host = the_host_name
      self.env['SERVER_NAME'] = the_host_name
      self.env['HTTP_HOST'] = the_host_name
    end
  end
end

then for test suites needing subdomained requests you can add this to your
setup:

@request.with_subdomain('primalgrasp')

Zsombor
-- 
Company  - http://primalgrasp.com
Thoughts - http://deezsombor.blogspot.com
_______________________________________________
Rails mailing list
Rails at lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails


		
---------------------------------
Relax. Yahoo! Mail virus scanning helps detect nasty viruses!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/2b37235a/attachment-0001.html


More information about the Rails mailing list