Hello, I know how to share sessions between subdomains in PHP. Can anyone please guide me as to how I can share sessions using Ruby? Where can I set the value of domain for which the cookie is set? I would like for a user to login on the home page and then go to blog.home.com and not have to login again. Any guidance/pointers are appreciated. Thanks'' Frank --------------------------------- Yahoo! Mail - Helps protect you from nasty viruses. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/48618a67/attachment.html
softwareengineer 99 wrote:> Hello, > > I know how to share sessions between subdomains in PHP. Can anyone > please guide me as to how I can share sessions using Ruby? Where can I > set the value of domain for which the cookie is set? > > I would like for a user to login on the home page and then go to > blog.home.com and not have to login again. > > Any guidance/pointers are appreciated. > > Thanks'' > FrankIsn''t that just a matter of how you have your cookie set? Instead of setting the domain of the cookie to ''blog.home.com'' just set it to ''.home.com'' and then that cookie should be valid for any host under the ''home.com'' domain. -- Posted via http://www.ruby-forum.com/.
sach wrote:> softwareengineer 99 wrote: >> Hello, >> >> I know how to share sessions between subdomains in PHP. Can anyone >> please guide me as to how I can share sessions using Ruby? Where can I >> set the value of domain for which the cookie is set? >> >> I would like for a user to login on the home page and then go to >> blog.home.com and not have to login again. >> >> Any guidance/pointers are appreciated. >> >> Thanks'' >> Frank > > Isn''t that just a matter of how you have your cookie set? > > Instead of setting the domain of the cookie to ''blog.home.com'' just set > it to ''.home.com'' and then that cookie should be valid for any host > under the ''home.com'' domain.I believe the question was ''how''... The answer is here: http://api.rubyonrails.com/classes/ActionController/Cookies.html -- Alex
softwareengineer 99
2006-Feb-08 13:13 UTC
[Rails] Re: Sharing sessions between subdomains?
Thanks Alex for your reply. Should the cookies be set in application.rb? I tried using cookies[:domain]=''domain.com'' but got an "undefined variable" error? Where should this setting for cookies be set if I want it to be applied on a application wide level? I also tried my controller file but to no avail? Then I placed the cookie settings in environment.rb. I don''t get an error but the session isn''t recognized on the subdomain? I appreciate your assistance very much. Thanks Frank Alex Young <alex@blackkettle.org> wrote: I believe the question was ''how''... The answer is here: http://api.rubyonrails.com/classes/ActionController/Cookies.html -- Alex _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails --------------------------------- Brings words and photos together (easily) with PhotoMail - it''s free and works with Yahoo! Mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/4251a150/attachment.html
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
softwareengineer 99
2006-Feb-08 14:26 UTC
[Rails] Re: Sharing sessions between subdomains?
Thanks for your reply. I am setting the cookie to .home.com in my login function but when I go to blog.home.com, the session isn''t being recognized. Can anyone please guide me on where is the optimal place to set the cookie? Thanks Frank sach <rubyforum@gaffle.com> wrote: softwareengineer 99 wrote:> Hello, > > I know how to share sessions between subdomains in PHP. Can anyone > please guide me as to how I can share sessions using Ruby? Where can I > set the value of domain for which the cookie is set? > > I would like for a user to login on the home page and then go to > blog.home.com and not have to login again. > > Any guidance/pointers are appreciated. > > Thanks'' > FrankIsn''t that just a matter of how you have your cookie set? Instead of setting the domain of the cookie to ''blog.home.com'' just set it to ''.home.com'' and then that cookie should be valid for any host under the ''home.com'' domain. -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails --------------------------------- Brings words and photos together (easily) with PhotoMail - it''s free and works with Yahoo! Mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/854d5145/attachment.html
softwareengineer 99
2006-Feb-08 14:33 UTC
[Rails] Re: Sharing sessions between subdomains?
Hi Zsombor, Thank you very much for your reply. I will test it out right now. Thanks again. Frank Dee Zsombor <dee.zsombor@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@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
softwareengineer 99
2006-Feb-08 15:05 UTC
[Rails] Re: Sharing sessions between subdomains?
Hello Zsombor, >> You need to set the session domain in your production.rb I placed the following code in production.rb, development.rb and test.rb ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => ''.domain.com'') and the functional tests snippet in test/test_helper.rb. Then I restarted the server and logged in at domain.com. Then I went to blog.domain.com and it''s not recognizing session and asking me again for password. Did I miss something? I highly appreciate your assistance. Frank P.S. I just added your blog to my reading list ;) --------------------------------- Brings words and photos together (easily) with PhotoMail - it''s free and works with Yahoo! Mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/32fa1660/attachment.html
softwareengineer 99
2006-Feb-08 15:08 UTC
[Rails] Re: Sharing sessions between subdomains?
I spoke too soon as after clearing the cookies it works! Zsombor, thank you so much for your time and assistance. I owe you one ;) Frank softwareengineer 99 <softwareengineer99@yahoo.com> wrote: Hello Zsombor, >> You need to set the session domain in your production.rb I placed the following code in production.rb, development.rb and test.rb ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => ''.domain.com'') and the functional tests snippet in test/test_helper.rb. Then I restarted the server and logged in at domain.com. Then I went to blog.domain.com and it''s not recognizing session and asking me again for password. Did I miss something? I highly appreciate your assistance. Frank P.S. I just added your blog to my reading list ;) --------------------------------- Brings words and photos together (easily) with PhotoMail - it''s free and works with Yahoo! Mail._______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails --------------------------------- Yahoo! Mail - Helps protect you from nasty viruses. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060208/2179653b/attachment-0001.html
On Feb 8, 2006, at 3:39 AM, softwareengineer 99 wrote:> Hello, > > I know how to share sessions between subdomains in PHP. Can anyone > please guide me as to how I can share sessions using Ruby? Where > can I set the value of domain for which the cookie is set? > > I would like for a user to login on the home page and then go to > blog.home.com and not have to login again. > > Any guidance/pointers are appreciated. > > Thanks'' > FrankFrank- I think this is what you need. This line goes in config/environments/ production.rb or development.rb: ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update ( :session_domain => ''.example.com'') Note the . before example.com , that is what makes the sessions work between subdomains. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com
> ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update > ( :session_domain => ''.example.com'')What if I don''t know session_domain at this stage. Can I set it up in controller? How? -- Posted via http://www.ruby-forum.com/.