我正在尝试使用以下代码在servlet中删除cookie:
Cookie minIdCookie = null;
for (Cookie c : req.getCookies()) {
if (c.getName().equals("iPlanetDirectoryPro")) {
minIdCookie = c;
break;
}
}
if (minIdCookie != null) {
minIdCookie.setMaxAge(0);
minIdCookie.setValue("");
minIdCookie.setPath("/");
res.addCookie(minIdCookie);
}
res.flushBuffer();
但是这没有任何影响,也没有改变cookie的属性。
我还尝试在这个servlet中添加一个cookie,这很好用。
为什么我不能更改现有cookie的属性呢?
.example.com
而不是example.com
即可。 - BalusC