In my spring-application I try to set a cookie and than redirect to a page where the cookie is read. The redirect to another webpage works, but setting the cookies fails only in IE9.
Cookie cookie = MyCookieHandler.createCookie(parameters, domain);
response.addCookie(cookie);
The redirect is handled buy setting the ModelAndView
modelView = new ModelAndView("redirect:" + getCallback());
As I said works fine in FF3+, Chrome and IE7/IE8. What wrong in my app? Any suggestions?
I had similar issues with IE 8, 9, and 10 and the cache control headers did not help. After further research, I had to put a P3P privacy policy (from an older Java web app) in place and IE stored the cookie properly without the cache control headers.
This policy format is only honored by Internet Explorer these days, but provides the only reliable means of managing cookies without manual changes in the IE privacy settings. There are two parts to a P3P privacy policy: policy file and compact policy header. The compact policy header seems to work well enough. The different categories of P3P have compact codes for brevity in the header, e.g. navigation => NAV. At a minimum, I would start with INT, NAV, and UNI codes for the compact policy.
Here are two examples of how to pass back the header:
Grails/Java:
response.setHeader("P3P", "CP='INT NAV UNI'");
PHP:
header('P3P:CP="INT NAV UNI"')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With