同域下,即使设置了cookie的路径还是能将不同路径cookie读出来。
1.在/ctf/day3/ 目录设置一个cookie
2.其他目录下是不能访问这个cookie的
3.通过iframe可以实现跨目录读取cookie
xc=function(src){ var o = document.createElement("iframe"); o.src = src; document.getElementsByTagName("body")[0].appendChild(o); o.onload=function() { d=o.contentDocument||o.contentDocument.document; alert(d.cookie); }; }("http://www.123.com/ctf/day3/index.php");
总结:通过设置path不能防止cookie被盗取。