Spring MVC HttpServletResponse does not overwrite cookie
Every time a different page is requested, I do the following:
Cookie cookie = new Cookie("c1", someString); // can be {a, b, c}, for example
cookie.setMaxAge(31556926);
response.addCookie(cookie);
cookie = new Cookie("c2", Integer.toString(someInt));
cookie.setMaxAge(31556926);
response.addCookie(cookie);
But when I am on page / page / a go to page / page / b (both of them follow the same method from the controller). I noticed that my cookies (from my web dev console in Chrome) have my new cookie BEFORE my old cookie ... causing the old cookie to be used by the client. I've tested this in Firefox as well. What am I doing wrong?
+3
source to share