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

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate