GeckoWebBrowser设置cookie

时间:2018-03-14 14:12:40   收藏:0   阅读:1155
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;
        }

 

原文:https://www.cnblogs.com/IWings/p/8566645.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!