void AddCookie (Cookie cookie)
{
if (cookies == null)
cookies = new CookieCollection ();
if (cookies.Count >= capacity)
RemoveOldest (null);
// try to avoid counting per-domain
if (cookies.Count >= perDomainCapacity) {
if (CountDomain (cookie.Domain) >= perDomainCapacity)
RemoveOldest (cookie.Domain);
}
// clone the important parts of the cookie
Cookie c = new Cookie (cookie.Name, cookie.Value);
c.Path = (cookie.Path.Length == 0) ? "/" : cookie.Path;
c.Domain = cookie.Domain;
c.ExactDomain = cookie.ExactDomain;
c.Version = cookie.Version;
c.Expires = cookie.Expires;
c.CommentUri = cookie.CommentUri;
c.Comment = cookie.Comment;
c.Discard = cookie.Discard;
#if NET_2_0
c.HttpOnly = cookie.HttpOnly;
#endif
c.Secure = cookie.Secure;
cookies.Add (c);
CheckExpiration ();
}