System.Net.CookieContainer.CookieContainer.Add C# (CSharp) Method

Add() public method

public Add ( Cookie cookie ) : void
cookie Cookie
return void
		public void Add (Cookie cookie) 
		{
			if (cookie == null)
				throw new ArgumentNullException ("cookie");

			if (cookie.Domain.Length == 0)
#if NET_2_0
				throw new ArgumentException ("Cookie domain not set.", "cookie.Domain");
#else
				throw new ArgumentException ("cookie.Domain");
#endif

			if (cookie.Value.Length > maxCookieSize)
				throw new CookieException ("value is larger than MaxCookieSize.");

			// .NET's Add (Cookie) is fundamentally broken and does not copy properties
			// like Secure, HttpOnly and Expires so we clone the parts that .NET
			// does keep before calling AddCookie
			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;
			
			AddCookie (c);
		}

Same methods

CookieContainer.CookieContainer::Add ( CookieCollection cookies ) : void
CookieContainer.CookieContainer::Add ( Uri uri, Cookie cookie ) : void
CookieContainer.CookieContainer::Add ( Uri uri, CookieCollection cookies ) : void