Register / Login
Win a copy of
Java EE 8 High Performance
this week in the
this forum made possible by our volunteer staff, including ...
Stephan van Hulst
Found Answer on to Delete a Cookie in servlet Request
posted 7 years ago
I asked how to delete a cookie in a
. I was always trying something like:
c.setMaxAge(0); //delete it c.setPath("/"); // anywhere on your work station response.addCookie(c);
but cookie would never go away. I would add setDomain, setSecure, etc, etc.
The trick is also to set the value. Why do you need to set a value if you are going to delete a cookie? Uhm,
anyway the following actually deletes a cookie
c.setMaxAge(0); //delete it c.setPath("/"); // anywhere on your work station c.setValue("timeToDelete"); response.addCookie(c);
Boost this thread!
setMaxAge(0) doesnt delete cookie?
Delete cookie code is not working in Opera and Mozilla browsers
can we retrieve cookie with JSP added thru servlet