本文介绍了如何在 Ruby on Rails 中的 cookie 上设置 HttpOnly 标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
页面保护您的 Cookie:HttpOnly解释了为什么制作 HttpOnly cookie 是个好主意.
The page Protecting Your Cookies: HttpOnly explains why making HttpOnly cookies is a good idea.
如何在 Ruby on Rails 中设置此属性?
How do I set this property in Ruby on Rails?
推荐答案
在用于设置 cookie 的哈希中设置 'http_only' 选项
Set the 'http_only' option in the hash used to set a cookie
例如
cookies["user_name"] = { :value => "david", :httponly => true }
或者,在 Rails 2 中:
or, in Rails 2:
例如
cookies["user_name"] = { :value => "david", :http_only => true }
这篇关于如何在 Ruby on Rails 中的 cookie 上设置 HttpOnly 标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!