Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

How will you delete a cookie?
To delete cookie from servlet, get the cookie from the request object and use setMaxAge(0) and then add the cookie to the response object. 

To delete cookie from JSP, use the following scriptlet:

<%
     Cookie killMyCookie = new Cookie("mycookie", null);
     killMyCookie.setMaxAge(0);
     killMyCookie.setPath("/");
     response.addCookie(killMyCookie);
%>

Posted By: Name:Rajesh Kr URL: How will you delete a cookie?