Rails 4跨子域的会话 [英] Rails 4 Session across subdomains
问题描述
我尝试以下,没有运气,试图在子域中持续会话:
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'
我在Google和SO上发现了所有这些组合。
I found all of these combinations on Google and SO.
我看到一些解释,但它涉及手动设置cookie。如果可能,我想坚持配置。
I saw a few explanations but it involved manually setting the cookie. I'd like to stick with configuration if possible.
注意:我正在使用devise。我还重新启动了服务器并清除了cookies。
Note: I'm using devise. I've also restarted the server and cleared cookies.
推荐答案
我发现不同的应用程序应该有相同的 secret_key_base
,位于 config / initializers / secret_token.rb
中。之后,我的所有应用程序都开始使用共享会话。
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。当然,他们应该有相同的会话密钥。
PS. Of course, they should have identical session keys.
这篇关于Rails 4跨子域的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!