if (value.length() != 0 && value.charAt(0) != '.'  && !value.equals(cookie.domain)) value = '.' + value;
    private static boolean setAttribute(Cookie cookie, String name,					String value, String set_cookie)	    throws ProtocolException    {	if (name.equalsIgnoreCase("expires"))	{	    if (value.charAt(value.length()-1) == '\"')		value = value.substring(0, value.length()-1).trim();	    try		// This is too strict...		// { cookie.expires = Util.parseHttpDate(value); }		{ cookie.expires = new Date(value); }	    catch (IllegalArgumentException iae)	    {		/* More broken servers to deal with... Ignore expires		 * if it's invalid		throw new ProtocolException("Bad Set-Cookie header: " +				    set_cookie + "\nInvalid date found at " +				    "position " + beg);		*/		Log.write(Log.COOKI, "Cooki: Bad Set-Cookie header: " + set_cookie +				     "\n       Invalid date `" + value + "'");	    }	}	else if (name.equals("max-age"))	// from rfc-2109	{	    if (cookie.expires != null)  return true;	    if (value.charAt(0) == '\"'  &&  value.charAt(value.length()-1) == '\"')		value = value.substring(1, value.length()-1).trim();	    int age;	    try		{ age = Integer.parseInt(value); }	    catch (NumberFormatException nfe)	    {		throw new ProtocolException("Bad Set-Cookie header: " +				    set_cookie + "\nMax-Age '" + value +				    "' not a number");	    }	    cookie.expires = new Date(System.currentTimeMillis() + age*1000L);	}	else if (name.equalsIgnoreCase("domain"))	{	    // you get everything these days...	    if (value.length() == 0)	    {		Log.write(Log.COOKI, "Cooki: Bad Set-Cookie header: " + set_cookie +				     "\n       domain is empty - ignoring domain");		return true;	    }	    // domains are case insensitive.	    value = value.toLowerCase();	    // add leading dot, if missing	    if (value.length() != 0 && value.charAt(0) != '.'  &&		!value.equals(cookie.domain))		value = '.' + value;	    // must be the same domain as in the url	    if (!cookie.domain.endsWith(value))	    {		Log.write(Log.COOKI, "Cooki: Bad Set-Cookie header: " + set_cookie +				     "\n       Current domain " + cookie.domain +				     " does not match given parsed " + value);		return false;	    }	    /* Netscape's original 2-/3-dot rule really doesn't work because	     * many countries use a shallow hierarchy (similar to the special	     * TLDs defined in the spec). While the rules in rfc-2965 aren't	     * perfect either, they are better. OTOH, some sites use a domain	     * so that the host name minus the domain name contains a dot (e.g.	     * host x.x.yahoo.com and domain .yahoo.com). So, for the seven	     * special TLDs we use the 2-dot rule, and for all others we use	     * the rules in the state-man draft instead.	     */	    // domain must be either .local or must contain at least	    // two dots	    if (!value.equals(".local")  && value.indexOf('.', 1) == -1)	    {		Log.write(Log.COOKI, "Cooki: Bad Set-Cookie header: " + set_cookie +				     "\n       Domain attribute " + value +				     "isn't .local and doesn't have at " +				     "least 2 dots");		return false;	    }	    // If TLD not special then host minus domain may not	    // contain any dots	    String top = null;	    if (value.length() > 3 )		top = value.substring(value.length()-4);	    if (top == null  ||  !(		top.equalsIgnoreCase(".com")  ||		top.equalsIgnoreCase(".edu")  ||		top.equalsIgnoreCase(".net")  ||		top.equalsIgnoreCase(".org")  ||		top.equalsIgnoreCase(".gov")  ||		top.equalsIgnoreCase(".mil")  ||		top.equalsIgnoreCase(".int")))	    {		int dl = cookie.domain.length(), vl = value.length();		if (dl > vl  &&		    cookie.domain.substring(0, dl-vl).indexOf('.') != -1)		{		    Log.write(Log.COOKI, "Cooki: Bad Set-Cookie header: " + set_cookie +					 "\n       Domain attribute " + value +					 "is more than one level below " +					 "current domain " + cookie.domain);		    return false;		}	    }	    cookie.domain = value;	}	else if (name.equalsIgnoreCase("path"))	    cookie.path = value;	else	  ; // unknown attribute - ignore	return true;    }