winForm写cookie经过

1.引进
名称空间 using System.Runtime.InteropServices;
2.注册
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
3.
#region 写入cookie
// set cookie
InternetSetCookie(url, "Token", "value=" + strToken +"; expires=Thu, 01-Jan-2020 00:00:01 GMT");
// navigate
webBrowser1.Navigate(url);
#endregion
注意      : InternetSetCookie (url地址,cookie名称,cookie内容及过期时间) 
expires过期时间格式应该为GMT

posted on 2012-04-27 16:16  HOT SUMMER  阅读(2867)  评论(0编辑  收藏  举报

导航