What is HttpOnly?

Source: Internet
Author: User

1. What is HttpOnly?
 
If you set the HttpOnly attribute in the cookie, the cookie information cannot be read through the js script, which effectively prevents XSS attacks. For more information, see google.
 
2. Does javaEE API support?
 
At present, sun has not released relevant APIs, but PHP and C # have all been implemented. The developers who are engaged in javaEE are quite depressed. Don't worry about the following changes.
 
3. HttpOnly setting example
 
JavaEE
1 response. setHeader ("Set-Cookie", "cookiename = value;
2 Path =/; Domain = domainvalue; Max-Age = seconds; HTTPOnly ");
The meaning of the specific parameter is not elaborated again. After the setting is complete, the cookie cannot be read through the js script, but the following method can be used to read
1 Cookie cookies [] = request. getCookies ();
C #
1 HttpCookie myCookie = new HttpCookie ("myCookie ");
2 myCookie. HttpOnly = true;
3 Response. AppendCookie (myCookie );
VB. NET
1 Dim myCookie As HttpCookie = new HttpCookie ("myCookie ")
2 myCookie. HttpOnly = True
3 Response. AppendCookie (myCookie)
 
However, in. NET 1.1, you must manually add
1 Response. Cookies [cookie]. Path + = "; HTTPOnly ";
PHP4
1 header ("Set-Cookie: hidden = value; httpOnly ");
 
PHP5
1 setcookie ("abc", "test", NULL, TRUE );
The last parameter is the HttpOnly attribute.
 
Reference
Http://www.owasp.org/index.php/HTTPOnly
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.