Example #1
0
        public void SetCookie(Cookie cookie)
        {
            if (cookie == null)
            {
                throw new ArgumentNullException("cookie");
            }
            Cookie new_cookie = cookie.Clone();
            int    added      = Cookies.InternalAdd(new_cookie, true);

            if (Logging.On)
            {
                Logging.PrintInfo(Logging.HttpListener, this, "SetCookie", " cookie#" + ValidationHelper.HashString(cookie));
            }
            if (added != 1)
            {
                // cookie already existed and couldn't be replaced
                throw new ArgumentException(SR.GetString(SR.net_cookie_exists), "cookie");
            }
        }