Chris Olsen
2008-Jun-19 19:38 UTC
How do you create one session cookie for multiple subdomains
I am using the restful authentication plugin and am always prompted to login if a different subdomain is accessed. I have found a couple rails "solutions", but none of them seem to work: # development.rb 1. ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = ".localhost" 2. ActionController::Base.session_options[:key] = ".localhost" Does anyone have a way that works? Thanks -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-19 19:54 UTC
Re: How do you create one session cookie for multiple subdomains
On 19 Jun 2008, at 20:38, Chris Olsen wrote:> > I am using the restful authentication plugin and am always prompted to > login if a different subdomain is accessed. I have found a couple > rails > "solutions", but none of them seem to work: > > # development.rb > 1. > ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] > = ".localhost" > 2. ActionController::Base.session_options[:key] = ".localhost" >config.action_controller.session = { :session_domain => ''texperts.local'', ... } works for me. session_key is the name of the cookie Fred> Does anyone have a way that works? > > Thanks > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Olsen
2008-Jun-19 20:38 UTC
Re: How do you create one session cookie for multiple subdom
Frederick Cheung wrote:> config.action_controller.session = { > :session_domain => ''texperts.local'', > ... > }After making the changes that you suggested I continually get InvalidAuthenticityToken exceptions. When I turned of protect_from_forgery I obviously never got the exceptions, but I was still unable to have one session key for more than one subdomain. This is what I now have: config.action_controller.session = { :session_domain => ".local", :session_key => ''_app_session'', :secret => ''secret_key'' } Is there anything that I am missing? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-19 20:47 UTC
Re: How do you create one session cookie for multiple subdom
On 19 Jun 2008, at 21:38, Chris Olsen wrote:> > Frederick Cheung wrote: >> config.action_controller.session = { >> :session_domain => ''texperts.local'', >> ... >> } > > After making the changes that you suggested I continually get > InvalidAuthenticityToken exceptions. When I turned of > protect_from_forgery I obviously never got the exceptions, but I was > still unable to have one session key for more than one subdomain. > > This is what I now have: > config.action_controller.session = { > :session_domain => ".local", > :session_key => ''_app_session'', > :secret => ''secret_key'' > } > > Is there anything that I am missing?You can''t set cookies for a top level domain like .local (in the same way that you can''t set a cookie for .com) the domain you set a cookie for must have at least two components (there are a lot of complications etc... see http://my.opera.com/yngve/blog/show.dml/ 267415 for example) Fred> > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Olsen
2008-Jun-19 21:23 UTC
Re: How do you create one session cookie for multiple subdom
Frederick Cheung wrote:> You can''t set cookies for a top level domain like .local (in the same > way that you can''t set a cookie for .com) the domain you set a cookie > for must have at least two components (there are a lot of > complications etc... see http://my.opera.com/yngve/blog/show.dml/ > 267415 for example) > > FredThanks for the info Fred. Once I set up my hosts file to point myappname.localhost to the loopback address (along with some additional test subdomains) and made all test app requests to that url, it allowed the cookie to be shared nicely. Thanks again. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Reese
2008-Dec-10 16:32 UTC
Re: How do you create one session cookie for multiple subdom
Chris Olsen wrote:> Frederick Cheung wrote: >> You can''t set cookies for a top level domain like .local (in the same >> way that you can''t set a cookie for .com) the domain you set a cookie >> for must have at least two components (there are a lot of >> complications etc... see http://my.opera.com/yngve/blog/show.dml/ >> 267415 for example)In case anyone had the same issue -- I was trying to get cross-subdomain cookies, as above. I followed the instructions... set my session_domain to ".myapp.local" to get around the issue Fred mentions, added some aliases to /etc/hosts, cleared my cookies, tried to log in to my app. And I was still getting InvalidAuthenticityToken errors. Turns out all I needed to do was restart Firefox. No idea why that worked, but the InvalidAuthenticityToken errors stopped. ymmv of course. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---