Techie Hints

A place where to find tech solution

Cookies Management in Spring MVC

Cookie cookie = new Cookie("user", user);
cookie.setPath("/Application");
cookie.setMaxAge(3600);
response.addCookie(cookie);

it needs to be removed as follows:

Cookie cookie = new Cookie("user", null); // Not necessary, but saves bandwidth.
cookie.setPath("/Application");
cookie.setMaxAge(0); // Don't set to -1 or it will become a session cookie!
response.addCookie(cookie);
%d bloggers like this: