i have used webservice into my application and want to delete information from cookies that is saved on one state and must be deleted on another state on particular condition given. How can i do so? Thanks
check http://www.ehow.com/how_5169279_remove-cookies-java.html
How can I delete a cookie from within a JSP page?
A cookie, mycookie, can be deleted using the following scriptlet:
<%
Cookie killMyCookie = new Cookie("mycookie", null);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);
%>
How do I delete a cookie set by a servlet?
Get the cookie from the request object and use setMaxAge(0)
and then add the cookie to the response object.
http://www.hccp.org/java-net-cookie-how-to.html
You can delete or unset cookies in JSP by setting setMaxAge()
for the cookie to zero.
For example:
Cookie[] cookies = request.getCookies();
cookies[0].setMaxAge(0);
response.addCookie(cookies[0]);
Here we collect all cookies and delete the first cookie by setting its age to zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With