I think you should use
response.removeCookie(key);
Question
I am using play 1.2.4. I have set a cookie and I am fetching the cookie using the below code --
@Util
public static void setCookie(String name, String value) {
// Setting cookie
response.setCookie(name, value);
}
public static Http.Cookie getCookie(String key) {
// retrieving cookie by key
return request.cookies.get(key);
}
and I am using the below code to remove the cookie --
public static void removeCookie(String key) {
// removing cookie by key
request.cookies.remove(key);
}
but the cookie is not getting removed.
Please suggest where am I going wrong?
N.B. - All the above codes are written in Application.java and I am calling the function from another controller.
Solution
I think you should use
response.removeCookie(key);
OTHER TIPS
To remove cookie be sure that you have already included play.mvc.Http.Cookie & play.mvc.Http.Request jar files. You can use this command to remove it.
response().discardCookie("name of cookie");