isGood

心中时常装有一盘人生的大棋,天作棋盘,星作棋子,在斗转星移中,只有不断地搏击人生,人生才有意义,生命才能彰显光辉,才能收获一分永恒。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

[转]winForm写cookie经过

Posted on 2011-08-31 16:05  isGood  阅读(890)  评论(0)    收藏  举报

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