I have two applications running on different rails versions; rails 2.3.18 and rails 4.2.1. I need to share the session between them so that logging into one application would also login into the other. I have the following configuration:
Rails 2.3
# config/initializers/session_store.rb
ActionController::Base.session = {
key: '_custom_session',
secret: 'xyz' }
# config/initializers/cookie_verification_secret.rb
ActionController::Base.cookie_verifier_secret = 'xyz'
Rails 4.2
# config/initializers/session_store.rb
Rails.application.config.session_store :cookie_store, key: '_custom_session'
Rails.application.config.action_dispatch.cookies_serializer = :marshal
Rails.application.config.secret_token = 'xyz'
# config/secrets.yml
# Removed the *secret_key_base*.
On logging into the Rails 4 app, a new cookie named _custom_session was created. The rails 2 app was also able to access the same cookie. This implied that the cookie was shared. However the user was not logged into the rails 2 app. Accessing the rails 2 app rewrote the shared cookie thus logging out the rails 4 user.
I also tried setting the domain manually, but that didn't help either:
Rails.application.config.session_store :cookie_store, key: '_custom_session', domain: '.rails.local'
Any help would be appreciated.