var uri = new Uri("http://www.aa.com"); //often cookies are stored on domain level, so ".google.com", not "www.google.com" (leading dot is important) string host = uri.Host.Replace("www", ""); CookieManager.Add(host, "/", "cookieName", "cookieValue", false, false, false, ConvertDateTimeInt(DateTime.Now.AddYears(3)));
/// <summary> /// DateTime时间格式转换为Unix时间戳格式 /// </summary> /// <param name="time"> DateTime时间格式</param> /// <returns>Unix时间戳格式</returns> public static int ConvertDateTimeInt(System.DateTime time) { System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); return (int)(time - startTime).TotalSeconds; }