Add cookieName Cookie:
Cookie newCookie = new Cookie("cookieName", "cookieValue");
newCookie.setMaxAge(60*60*24*365); //Store cookie for 1 year
response.addCookie(newCookie);
and then remove it:
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("cookieName")) {
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
resp.addCookie(cookie);
}
}
}