// // Set a cookie using parameters // public HttpCookie SetCookie(string name, string value, string domain = null, DateTime? expires = null, TimeSpan? max_age = null) { if (name == null) throw new ArgumentNullException("name"); if (value == null) throw new ArgumentNullException("value"); if (expires.HasValue && max_age.HasValue) throw new ArgumentException("setting expires and max age doesn't make sense"); var cookie = new HttpCookie(name, value) { Domain = domain, }; if (expires.HasValue) cookie.Expires = expires.Value; if (max_age.HasValue) cookie.Expires = DateTime.Now + max_age.Value; SetCookie(name, cookie); return cookie; }
// // Set a cookie using a cookie object // public void SetCookie(string name, HttpCookie cookie) { Cookies[name] = cookie; }