在设备中的两个Web应用程序之间共享会话 [英] Share a session between two web applications in device
问题描述
我有多个申请。我希望能够使用cookie_store在他们之间共享会话。
I have more than one applications. I want to be able to share a session between them using cookie_store.
应用程序A:
before_filter :authenticate_from!
def authenticate_from!
unless session['warden.user.user.key'].nil?
@user=User.find_or_initialize_by_id(ky[1])
sign_in @user
end
end
它可以工作,但是无法识别应用程序B会话。
我应该怎么做?
It can work, but application B session can not be identified. What should I do?
推荐答案
可以做到,但是这两个应用程序都需要有一个共同点子域和您配置中的 secret_token
值必须相同。
This can be done, but both of these applications will need to have a common subdomain and the secret_token
value in your configuration will have to be identical.
例如,您可以拥有 app1.example.com
和 app2.example.com
,只要将Cookie分配给。 example.com
。
For instance, you can have app1.example.com
and app2.example.com
so long as the cookie is assigned to .example.com
.
此选项存储在 config / initializers / session_store.rb $ c中$ c>和
config / initializers / secret_token.rb
。
请注意,请确保您的秘密令牌值与默认安装中的一样长且随机。不要只是切换到简短方便的方式。
As a note, ensure that your secret token value is as long and random as in a default install. Don't just switch to something short and convenient.
这篇关于在设备中的两个Web应用程序之间共享会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!