>> Hi all, >> >> Ive got a login form for users with the fields subdomain, username and >> password. This is at the URLhttp://domain.com. >> >> When the user submits the form and login is successful, i need the URL >> to change tohttp://subdomain.domain.com/whatever. >> How can I do this? > > You need to set your session cookie to apply to the whole domain (so > that when it is set from the page at domain.com it is also sent when > the browser requests subdomain.domain.com. It's one of the session > options you can set in environment.rb > > Fred >> >> My try was >> >> if no_subdomain? >> redirect_to "http://#{params[:subdomain]}.domain.com/whatever" >> else >> redirect_to whatever_path >> end >> >> But I think the session data is lost when you redirect like above. So >> it takes me back to the login form. >> Any ideas?
Set the following in your config/environments/production.rb file: ActionController::Base.session_options[:session_domain] = 'domain.com' This will store the session cookie on domain.com which will then also be readable on subdomain.domain.com Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---