In a Java Servlet how can I change the value of an existing cookie? There is an addCookie method, but no deleteCookie or editCookie in HttpServletResponse
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Those indeed don’t exist. Just create utility methods yourself which do that. Particularly getting the desired cookie is quite bloated. E.g.
To edit a cookie, set its value and then add it to the response:
Set if necessary the maxage, path and domain as well if they differs from your default. The client namely doesn’t send this information back.
To delete a cookie, set the max age to
0(and preferably also the value tonull):Set if necessary the path and domain as well if they differs from your default. The client namely doesn’t send this information back.