Online Java Compiler By
JavaTpoint.com
import java.net.HttpCookie; public class JavaHttpCookieDomainMatchesExample1 { public static void main(String[] args) { String domain = "www.localhost.com", host = "www.javatpoint.com"; HttpCookie cookie = new HttpCookie("Employee", "5"); //Returns true if the domain matches. Otherwise, returns false. System.out.println("Tests whether a host name lies in the domain or not: "+cookie.domainMatches(domain, host)); } }
Output