设计管理的会话不会传播到子域 [英] Devise-managed session not propagating to subdomains

查看:91
本文介绍了设计管理的会话不会传播到子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Devise来管理Rails 3.1应用程序中的身份验证。它在我的生产服务器中工作得很好。但是我刚刚设置了一个新的测试服务器,如果我登录到主站点,访问一个子域不会识别该会话。这是要求我再次登录。

I am using Devise to manage authentication in a Rails 3.1 application. It works just fine in my production server. But I just set up a new test server, and if I log in to the main site, accessing a subdomain is not recognizing the session. It's asking me to log in again.

我不记得在哪里我会排除这些信息。看起来好像是一些cookie设置。

I can't recall where I would troubleshoot this information. It seems as if it is some cookie setting.

我有域指向每个站点,生产和测试。生产一个以.net结尾,测试版以.co结尾。

I have domains pointed to each site, production and test. The production one ends in .net, the test version ends in .co.

任何人都可以指向正确的方向?

Can anyone point me in the right direction?

推荐答案

我认为这不是一个设计设置,而是一个会话和cookie设置。

I think this is not a devise setting but a session and cookie setting.

您可以通过设置变量 YourApp :: Application.config.session

您可以在 environment.rb 文件或您的 config / initializers / session_store.rb 。 session_store.rb的示例是

You can do this in your environment.rb file or your config/initializers/session_store.rb. Example for session_store.rb is

YourApp::Application.config.session = {
 :session_domain => '.yourdomain.com',
 :session_key => '_yourapp',
 :expire_after => 14*24*3600,
 #:secure => true, #for secure/ssl sessions and such
 :secret      => 'somesecretgobledygook' 
}

请注意 session_domain 将其设置为 .yourdomain.com 使您的Cookie在子域中工作。

Please note the session_domain setting it to .yourdomain.com makes your cookies work across subdomains.

这适用于会话。 Cookie类似的设置。

This applies to sessions. There are similiar settings for cookies.

这篇关于设计管理的会话不会传播到子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆