Repository navigation
Using with Multiple Sites
This is more than likely a newbie question, but I don’t see it covered anywhere.
The scenario is:
I have two sites, one for back-end editing, one for front-end viewing. These are two separate Rails projects that share a single database. A team of reporters enters content into the back-end that shows up in the front-end.
The back-end uses acts-as-authenticated. The front-end does not (because it’s public).
The problem is, when the reporter (or anyone) logs into the back-end, and then goes to look at the front-end, the front-end clears the session, and now they have to log back into the back-end.
Is there a way to avoid this?
Thanks in advance!
—————
Then make the front-end stop clearing the session. Simple really. Maybe you’re having issues with your session? Also, separate apps use separate session keys I believe. If not, they may be clobbering each other.
The SessionManagement module shows how to modify the session. Use the session class method in your controllers to modify session properties for a group of actions, or config.session_options in environment.rb to change the default options.
ActionController::Base.process_cgi lists the possible session options.
This wiki probably isn’t the best place to ask questions. Try Rails Weenie.
—————
The problem you are having is two cookies that creates two sessions. Let say you ahve two sites with these two URLs: admin.domain.com and www.domain.com. For such a situation what you need to do is setup your session to use the domain ”.domain.com”. Then your browser will create only one cookie for both domains and you will end up with only one session.
Hope it helps,
Adrian Madrid
————————
Check out:
1. class ApplicationController < ActionController::Base 2. # … 3. 4. DOMAINS = [‘example.com’, ‘example.net’].freeze 5. 6. DOMAINS.each do |domain| 7. session :session_domain => “.#{domain}”, :if => lambda { |request| request.host.dup.chomp!(domain) } 8. end 9. 10. # … 11. endhttp://www.railsweenie.com/forums/1/topics/597