The page Protecting Your Cookies: HttpOnly explains why making HttpOnly cookies is a good idea.
How do I set this property in Ruby on Rails?
Set HttpOnly cookie in PHPini_set("session. cookie_httponly", True); This is the most common way to set cookies in PHP, empty variables will hold their default value.
What is HttpOnly? According to the Microsoft Developer Network, HttpOnly is an additional flag included in a Set-Cookie HTTP response header. Using the HttpOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).
I've been told that putting httpOnly:true on the cookie prevents the browser from editing cookies, but I can still edit it on my local server. A HTTP only cookie prevents JavaScript from modifying cookies, not the browser.
Set the 'http_only' option in the hash used to set a cookie
e.g.
cookies["user_name"] = { :value => "david", :httponly => true }
or, in Rails 2:
e.g.
cookies["user_name"] = { :value => "david", :http_only => true }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With