remove servlet Cookie - Java Servlet JSP

Java examples for Servlet JSP:Cookie

Description

remove servlet Cookie

Demo Code


import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static void removeCookie(HttpServletResponse response,
            String name) {/*from   w ww . j a  va  2  s .  c om*/
        Cookie cookie = new Cookie(name, "");
        cookie.setHttpOnly(true); // Tell browser to not make this cookie available to javascript.
        cookie.setMaxAge(0);
        cookie.setPath("/");
        response.addCookie(cookie);
    }
}

Related Tutorials