configurations / Initializers / session_store.rb
ProjectName::Application.config.session_store :cookie_store, key: '_ProjectName_session', domain: :all, tld_length: 2
And then you also need to clear the cookies.
UPD: my previous answer was wrong, I forgot to add the tld_length
parameter, so the session is not split between domains with a top-level domain longer than 1 (myapp.local has tld_length 2). Now the answer is correct.
source share