Jatinder Singh
2006-Jun-29 10:07 UTC
[Rails] session management not working for me in an exceptional condition
I have an RoR application(parent) which can be used to kickstart other RoR applications(child). A user can log in to parent RoR and then start child RoR''s and then visit that RoR using one of the links provided in parent RoR; I have following html code is parent RoR list page for visiting an child RoR <input type=button onclick="visitApp1()" value="Application1"> </input> <script> function visitApp1() { window.open("http://localhost:3001/ror2/list") } </script> I start parent RoR at 3000 port and then I visit it using IE ( http://localhost:3000/ror1) on the list page of ror1 when I click Application1 button, a new browser window opens which shows RoR2 correctly; but the my RoR1 gets disturbed, when I try to view any other page in ror1, it throws me back to the login window of ror1(in the controller of ror1, I have specified a before_filter :authorize which checks if user has logged in using session[:user_d]) My question is that why the session of parent RoR gets reset after opening a new browser(with URL http://localhost:3001/...)?? One observation: when I invoke RoR1 by http://my-machine-name:3000/ror1 and then open child ror''s the session of ror1 does not break.. when I change the code above the invoke new application using my machine name instead of "localhost" session does not break provided I have invoked ror1 with localhost. What I suspect is somehow the session is getting moved from parent to child window. Any help is appreciated. Jatinder -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060629/1492b042/attachment.html
Ezra Zygmuntowicz
2006-Jun-29 15:48 UTC
[Rails] session management not working for me in an exceptional condition
On Jun 29, 2006, at 3:07 AM, Jatinder Singh wrote:> I have an RoR application(parent) which can be used to kickstart > other RoR applications(child). > A user can log in to parent RoR and then start child RoR''s and then > visit that RoR using one of the links provided in parent RoR; I > have following html code is parent RoR list page for visiting an > child RoR > > <input type=button onclick="visitApp1()" value="Application1"> </ > input> > > <script> > function visitApp1() > { > window.open(" http://localhost:3001/ror2/list") > } > > </script> > > I start parent RoR at 3000 port and then I visit it using IE > (http://localhost:3000/ror1) > on the list page of ror1 when I click Application1 button, a new > browser window opens which shows RoR2 correctly; but the my RoR1 > gets disturbed, when I try to view any other page in ror1, it > throws me back to the login window of ror1(in the controller of > ror1, I have specified a before_filter :authorize which checks if > user has logged in using session[:user_d]) > My question is that why the session of parent RoR gets reset after > opening a new browser(with URL http://localhost:3001/...)?? > > One observation: when I invoke RoR1 by http://my-machine-name:3000/ > ror1 and then open child ror''s the session of ror1 does not break.. > when I change the code above the invoke new application using my > machine name instead of "localhost" session does not break provided > I have invoked ror1 with localhost. > > What I suspect is somehow the session is getting moved from parent > to child window. > > Any help is appreciated. > > Jatinder >Yeah your sessions are stepping on each other. What i recommend is that you set up some aliases in your /etc/hosts file so that you can use different domains names for each of your apps. # in /etc/hosts 127.0.0.1 ror1 ror2 ror3 THis way you can use urls like: http://ror1:3000 http://ror2:3001 http://ror3:3002 Cheers- -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060629/738d5b12/attachment.html