IE 9 sets cookie and redirects crash

In my spring application, I am trying to set a cookie and redirect to the page where the cookie is being read. Redirecting to another web page works, but setting cookies is only completed in IE9.

Cookie cookie = MyCookieHandler.createCookie(parameters, domain); response.addCookie(cookie); 

A redirect is processed when buying a ModelAndView model

 modelView = new ModelAndView("redirect:" + getCallback()); 

As I said, it works fine in FF3 +, Chrome, and IE7 / IE8. What is wrong with my application? Any suggestions?

+8
java redirect spring internet-explorer cookies
source share
3 answers

After some attempts, I added the following:

 response.addHeader("Pragma", "no-cache"); response.addHeader("Cache-Control", "no-cache"); 

Now it works for me, I don’t know if this solution is right, and I don’t know why caching is different in IE9, but now it works ... thanks guys.

+3
source share

I had similar problems with IE 8, 9, and 10, and the cache control headers did not help. After further research, I had to put the P3P privacy policy (from the old Java web application) and IE correctly saved the cookie without cache control headers.

This policy format is only respected by Internet Explorer these days, but it is the only reliable cookie management tool without manual changes to IE's privacy settings. The P3P privacy policy has two parts: the policy file and the compact policy header. The compact policy header seems to work quite well. The various categories of P3P have compact codes for brevity in the title, for example. navigation => NAV. At a minimum, I would start with INT, NAV, and UNI codes for compact politics.

Here are two examples of returning a header:

 Grails/Java: response.setHeader("P3P", "CP='INT NAV UNI'"); PHP: header('P3P:CP="INT NAV UNI"') 
+5
source share

I had a failed redirect problem before. This oddly seemed to work in Firefox, but failed in IE. The solution was to add the full URL to the redirect operator, i.e.

 http://foo.com/new_site.html 

instead

 new_site.html 
+2
source share

All Articles