Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieSetDiscardExample2 { public static void main(String[] args) { HttpCookie cookie = new HttpCookie("Employee", "4"); // Specifies whether the given user agent can discard the cookie unconditionally or not. cookie.setDiscard(true); //Returns the discard attribute of the cookie. System.out.println("Checks the discard attribute of the cookie: "+cookie.getDiscard()); } }
Output