如何将会话cookie的HttpOnly设置为false?

时间:2010-04-21 01:11:36

标签: ruby-on-rails session cookies httponly

在Ruby on Rails中,如何将会话cookie的httpOnly设置为false?

4 个答案:

答案 0 :(得分:7)

我想出来了。在/config/environment.rb中包含此代码:

config.action_controller.session = { :httponly => false }

答案 1 :(得分:7)

在Rails 4中,您需要修改config/initializers/session_store.rb

Rails.application.config.session_store :cookie_store,
  key: '_my_app_session', httponly: false

答案 2 :(得分:6)

这就是我使用Rails 3的方式:

Testapp::Application.config.session_store :cookie_store, key: '_testapp_session', :domain => :all, :httponly => false

答案 3 :(得分:0)

Rails默认设置为true。 我不建议更改它,因为它会设置您可以从JS更改的cookie,如:document.cookie

在Rails 3+中,您可以从config/initializers/session_store.rb更改Cookie配置:

# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: "_my_application_session", httponly: false