Rails 4 Session across subdomains

吃可爱长大的小学妹 提交于 2019-12-09 16:23:54

问题


I'm trying the following with no luck in an attempt to persist sessions across subdomains:

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => :all, :tld_length => 2

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => 'myapp.dev'

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => '.myapp.dev'

I found all of these combinations on Google and SO.

I saw a few explanations but it involved manually setting the cookie. I'd like to stick with configuration if possible.

Note: I'm using devise. I've also restarted the server and cleared cookies.


回答1:


I found that different applications should have identical secret_key_base, located in config/initializers/secret_token.rb. After I did this, all my applications is started to use shared session.

PS. Of course, they should have identical session keys.



来源:https://stackoverflow.com/questions/21262462/rails-4-session-across-subdomains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!