/// <summary>
 /// Adds an
 /// <see cref="Org.Apache.Http.Cookie.Cookie">HTTP cookie</see>
 /// , replacing any existing equivalent cookies.
 /// If the given cookie has already expired it will not be added, but existing
 /// values will still be removed.
 /// </summary>
 /// <param name="cookie">
 /// the
 /// <see cref="Org.Apache.Http.Cookie.Cookie">cookie</see>
 /// to be added
 /// </param>
 /// <seealso cref="AddCookies(Org.Apache.Http.Cookie.Cookie[])">AddCookies(Org.Apache.Http.Cookie.Cookie[])
 ///     </seealso>
 public virtual void AddCookie(Org.Apache.Http.Cookie.Cookie cookie)
 {
     lock (this)
     {
         if (cookie != null)
         {
             // first remove any old cookie that is equivalent
             cookies.Remove(cookie);
             if (!cookie.IsExpired(new DateTime()))
             {
                 cookies.AddItem(cookie);
             }
         }
     }
 }