Create a secret key base for your cookies encryption.

rake secret

Copy and paste the generated key into secrets.yml for all the rails app that you want to share the cookies session. They need to have the same key in order to decrypt cookies.

production:
    secret_key_base: the_key_that_you_have_generated

Next, you need to update your session_store initializer to enable the sharing.

Rails.application.config.session_store :cookie_store, key: '_your_session', :domain => :all, :tld_length => 2, secure: true

The key config here is domain=all which creates cookies for all sub-domains. tld_length define the top level domain length. For example, sub1.domain.com, your tld_length will be 2. Finally, the secure config tells the browser to send cookies only for secure connection.