您的位置:首页 > 其它

从WebBrowser中取得Cookie 和 WebClient设置cookie!

2008-03-05 11:09 357 查看
从WebBrowser中取得Cookie 的代码

CookieContainer myCookieContainer = new CookieContainer();

string cookieStr = webBrowser1.Document.Cookie;

string[] cookstr = cookieStr.Split(';');

foreach (string str in cookstr)

WebClient设置cookie!

WebClient wc = new WebClient();

wc.Headers.Add("Cookie", "PHPSESSID=" + cookie + ";");

//~~~~~~~注意,这里是Cookie,不是Set-Cookie

byte[] re = wc.UploadData(Global.RootPath + "test.php", new byte[0]);

System.Text.UTF8Encoding converter = new System.Text.UTF8Encoding();

string str = converter.GetString(re);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: