Deleting the cookies
Sometimes it is required to delete the cookies, where we need to set the MaxAge to 0.
Here we are retrieving the cookies from the request, and setting the maxAge to "0" to the response , so that it will expire the cookies.
Cookie[] cookies = request.getCookies();
for(Cookie cookie : cookies){
System.out.println("cookie Name is "+cookie.getName());
cookie.setMaxAge(0);
response.addProperty(cookie);
}
Comments
Post a Comment