日期:2014-05-18 浏览次数:20889 次
public static void SetObj(string strCookieName, int iExpires, string strValue) { HttpCookie objCookie = new HttpCookie(strCookieName.Trim()); objCookie.Value = Utils.EncodeURIComponent(strValue.Trim()); objCookie.Domain = N0.Config.CommonConfig.strDomain; if (iExpires > 0) { if (iExpires == 1) { objCookie.Expires = DateTime.MaxValue; } else { objCookie.Expires = DateTime.Now.AddSeconds(iExpires); } } HttpContext.Current.Response.Cookies.Add(objCookie); }
//构造cookie CookieContainer snCookie = new CookieContainer(50); snCookie .PerDomainCapacity = 50; CookieCollection sn132Collection3 = CookieArray.GetCookies(Datas.liveUri); for (int i = 0; i < sn132Collection3.Count; i++) { Cookie testC = new Cookie(); testC = sn132Collection3[i]; testC.Domain = "." + Datas.serverAddress; sn132Cookie.Add(new Uri(sendMailLink), testC); }
------解决方案--------------------
http://blog.csdn.net/porschev/archive/2011/05/10/6408543.aspx