我正在开发一个(J2EE)网站,它发送的cookie正在Chrome和Firefox上保留,但不是IE。我甚至将IE设置为'允许所有cookie',但我网站上的那些没有被保留。谷歌,Twitter等,cookie确实存在。
以下是我创建并传递cookie(HTTP)的代码:
Cookie rememberMeCookie = new Cookie("tms-remember-me", username);
rememberMeCookie.setPath("; HttpOnly");
rememberMeCookie.setMaxAge(365*24*60*60);
rememberMeCookie.setSecure(false);
rememberMeCookie.setVersion(1);
response.addCookie(rememberMeCookie);
response.setHeader("P3P", "CP=\"CURa ADMa DEVa CONo HISa OUR IND DSP ALL COR\"");
使用Fiddler for IE,我看到我的登录页面正确发送了一个cookie:
Response sent 65 bytes of Cookie data:
Set-Cookie: JSESSIONID=1B7FCA42674BB275364A71F8BCEA4F4E; Path=/tms/; HttpOnly
Response sent 121 bytes of Cookie data:
Set-Cookie: tms-remember-me=superuser; Version=1; Max-Age=31536000; Expires=Fri, 16-Jun-2017 01:03:13 GMT; Path="; HttpOnly;"; Secure
P3P Header is present:
CP="CURa ADMa DEVa CONo HISa OUR IND DSP ALL COR"
但是IE仍然不会持久化cookie - 当我访问我的登录页面时,HttpServletRequest getCookies()仅包含JSESSIONID
cookie,而不包含我的tms-remember-me
cookie。但如果我使用Chrome或FF,它就会出现。知道为什么不为IE?