访问“会话密钥” cookie名称从Rails的任何地方 [英] Accessing the "session key" cookie name from anywhere in Rails

查看:122
本文介绍了访问“会话密钥” cookie名称从Rails的任何地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个用于在iframe Facebook应用程序中使用的Rails插件,我们需要检查Rail的会话ID cookie是否已设置。

We are building a plugin for Rails to be used within iframe Facebook applications, and at one point we need to check if Rail's session id cookie as been set or not.

默认情况下,此cookie名为 _myprojectname_session ,我们需要找到的是cookie本身的实际名称。所以如果没有设置,我们可以做一些重定向,以确保cookie设置。

By default, this cookie is named _myprojectname_session, what we need to find out is the actual name of the cookie itself. So if it's not set, we can do some redirects to make sure the cookies are set.

我们如何从任何地方访问cookie的名字?

How do we access the damn name of the cookie from anywhere? Or at least from within a controller?

推荐答案

我找到了解决方案。在Rails 2.3.2中,至少会话密钥在 config / initializers / session_store.rb 中设置如下:

I found the solution. In Rails 2.3.2 at least the session key in set in config/initializers/session_store.rb like this:

ActionController::Base.session = {
  :key         => '_myapp_session',
  :secret      => '[...]'
}

ActionController::Base.session_options[:key]

Base.session Base.session_options 没有什么意义,这让我很头痛... lol

From Base.session to Base.session_options automagically, doesn't make much sense, and it caused me a big headache... lol

这篇关于访问“会话密钥” cookie名称从Rails的任何地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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