XSS - 禁止浏览器读取Cookie - HttpOnly
1.什么是HttpOnly?
如果您在cookie中设置了HttpOnly属性,那么通过js脚本将无法读取到cookie信息,这样能有效的防止XSS攻击,具体一点的介绍请google进行搜索。
C#
HttpCookie myCookie =
new
HttpCookie(
"myCookie"
);
myCookie.HttpOnly =
true
;
Response.AppendCookie(myCookie);
javaee
response.setHeader(
"Set-Cookie"
, "cookiename=value;
Path=/;Domain=domainvalue;Max-Age=seconds;HTTPOnly");