Rails 3 - “无限”更改为 session_store 时的会话:domain => :全部

发布于 2024-10-20 08:34:43 字数 761 浏览 6 评论 0原文

我目前有基于 cookie 的会话。我试图允许使用同一会话访问我的系统上的所有子域,因此用户只需登录一次并被授予通过我的网站(section1.mysite.com、section2.mysite.com 等)的访问权限。

我已经更新了我的 config/initializers/session_store.rb ,如下所示:

 Mysite::Application.config.session_store :cookie_store, :key => '_mysite_session', :domain => :all
 #Mysite::Application.config.session_store :cookie_store, :key => '_mysite_session'

注释掉的行显示了我之前的内容。现在,如果我在重新启动服务器时注销(没有保存 cookie 会话),这会非常有效。但是,如果我有第一个配置的 cookie 会话,当我切换到 :domain => 时总之,我不能破坏那个会话。用户无限期地登录,因为会话不会破坏。用户无法从已注释掉的会话配置上登录的会话中注销,并且在新配置到位后他们会尝试注销。

我尝试过的事情: * 更改 security_token 似乎没有帮助 * 更改 session_store 键似乎没有帮助(我对此感到困惑......我认为它应该起作用) * 在我的一生中,我无法找到如何手动删除会话

无论我做什么,在我进行此更改之前登录的任何人都无法在我这样做后注销。

预先感谢您的帮助! 本

I currently have cookie based sessions. I am trying to allow access to all subdomains on my system with the same session, so users will only login once and be granted access through my site (section1.mysite.com, section2.mysite.com, etc).

I have updated my config/initializers/session_store.rb like so:

 Mysite::Application.config.session_store :cookie_store, :key => '_mysite_session', :domain => :all
 #Mysite::Application.config.session_store :cookie_store, :key => '_mysite_session'

The commented out line shows what I had before. Now, this works great if I was logged out (had no cookie session saved) when I restarted the server. However, if I had a cookie session for the first configuration, when I switch to :domain => all, I cannot destroy that session. The user is indefinitely logged in, because the session will not destroy. Users are not be able to logout from their sessions where the login was on the commented out session configuration, and they attempt to logout once the new config is in place.

Things I've tried:
* changing the security_token didnt seem to help
* changing the session_store key didn't seem to help (I'm confused about this... i thought it should work)
* for the life of me I can't find out how to manually delete the sessions

No matter what I do, anyone logged in before I make this change cannot logout once I do.

Thanks in advance for your help!
Ben

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送君千里 2024-10-27 08:34:43

:domain 选项不应该是复数吗,如 :domains 中那样?

在您的情况下,这样做:

Mysite::Application.config.session_store :cookie_store,
  :key => '_mysite_session', :domains => :all

为了摆脱持久会话,您可能需要清除浏览器 cookie。

更新:

要删除用户 cookie,请编辑以下 Rails 文件:

app/config/initializers/secret_token.rb:

Mysite::Application.config.secret_token= 'XXXXXXXXX...XXXXXXXXX'

Shouldn't the :domain option be plural, as in :domains?

In your case, that would do:

Mysite::Application.config.session_store :cookie_store,
  :key => '_mysite_session', :domains => :all

And in order to get rid of your persistent session, you may want to clear your browser cookies.

Update:

To get rid of users cookies, edit the following Rails file:

app/config/initializers/secret_token.rb:

Mysite::Application.config.secret_token= 'XXXXXXXXX...XXXXXXXXX'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文