Share session between two rails4 applications

前端 未结 2 1677
既然无缘
既然无缘 2021-01-16 08:01

I am creating a application with devise. there is two domain name 1) www.test.com and 2) www.hello.com both domain pointing to same application. so I want to share session(c

2条回答
  •  失恋的感觉
    2021-01-16 08:59

    Rails maintain cookie which gets passed on to the server during every HTTP request. Please check the request headers under your network logs

    You will see something like this

    Cookie: some-junk-looking-session-data
    

    So sharing session between two entirely different rails application is a security issue and rails don't allow this kind of behaviour.

    However, there is an exception. A session can be shared if just the TLD changes. Eg: hello.com & hello.org.

    YourApp::Application.config.session_store :cookie_store,
      key: '_app_session',
      domain: :all
    

    References:

    https://github.com/rails/rails/commit/1091a6e9b700bd713c8a6818761a27aa72b1fe93

提交回复
热议问题