/** * Create a new cookie with domain, name, value, path and expires. * * @param domain the domain * @param name the name * @param value the value * @param path the path * @param expires the expires * @return a new cookie */ protected Cookie createCookie( String domain, String name, String value, String path, long expires) { Cookie cookie = new Cookie(); cookie.setDomain(domain); cookie.setName(name); cookie.setValue(value); cookie.setPath(path); cookie.setExpiryDate(new Date(System.currentTimeMillis() + expires)); return cookie; }
/** Parse cookie path attribute. */ public void parse(final Cookie cookie, final String path) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (path == null) { throw new MalformedCookieException("Missing value for path attribute"); } if (path.trim().equals("")) { throw new MalformedCookieException("Blank value for path attribute"); } cookie.setPath(path); cookie.setPathAttributeSpecified(true); }