WinFrom 写COOKIE

        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
       
        public static void SetCookie(string url, string Cookies, DateTime dt)
        {
           string cookieTime = ";expires=" + dt.ToString("r");
            foreach (var v in Cookies.Split(';'))
            {
                InternetSetCookie(url, null, v + cookieTime);
            }
        }

//dt.ToString("r");   返回GMT格式。。。

posted on 2012-01-13 11:12  CosmoKey  阅读(367)  评论(0编辑  收藏  举报

导航