HttpCookie.HttpOnly Property
Assembly: System.Web (in system.web.dll)
/** @property */ public boolean get_HttpOnly () /** @property */ public void set_HttpOnly (boolean value)
public function get HttpOnly () : boolean public function set HttpOnly (value : boolean)
Not applicable.
Property Value
true if the cookie has the HttpOnly attribute and cannot be accessed through a client-side script; otherwise, false. The default is false.Microsoft Internet Explorer version 6 Service Pack 1 and later supports a cookie property, HttpOnly, that can help mitigate cross-site scripting threats that result in stolen cookies. Stolen cookies can contain sensitive information identifying the user to the site, such as the ASP.NET session ID or forms authentication ticket, and can be replayed by the attacker in order to masquerade as the user or obtain sensitive information. When an HttpOnly cookie is received by a compliant browser, it is inaccessible to client-side script.
Caution: |
|---|
| Setting the HttpOnly property to true does not prevent an attacker with access to the network channel from accessing the cookie directly. Consider using Secure Sockets Layer (SSL) to help protect against this. Workstation security is also important, as a malicious user could use an open browser window or a computer containing persistent cookies to obtain access to a Web site with a legitimate user's identity. |
For more information on possible attacks and how this property can help mitigate them, see Mitigating Cross-site Script.
Caution: