In 2002, Microsoft introduced a new cookie property called “HttpOnly.” While you can set the property programmatically on a per-cookie basis, you also can set it globally in the site configuration.
Message boards, forums, and wikis are also often vulnerable to application security issues. In these sites, legitimate users post their thoughts or opinions, which are then visible to all other visitors to the site. But an attacker, rather than posting about the current topic, will instead post a message such as “<script>alert(document.cookie);</script>”. The message board now includes the attacker’s script code in its page code-and the browser then interprets and executes it for future site visitors. Usually attackers use such script code to try to obtain the user’s authentication token (usually stored in a cookie), which they could then use to impersonate the user. When cookies are marked with the “HttpOnly” property, their values are hidden from the client, so this attack will fail.
As mentioned earlier, it is possible to enable “HttpOnly” programmatically on any individual cookie by setting the “HttpOnly” property of the “HttpCookie” object to “true.” However, it is easier and more reliable to configure the application to automatically enable “HttpOnly” for all cookies. To do this, set the “httpOnlyCookies” attribute of the <httpCookies> element to “true.