我有一个CookieAwareWebClient
public class CookieAwareWebClient : WebClient
{
private CookieContainer cookie = new CookieContainer();
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request is HttpWebRequest)
{
(request as HttpWebRequest).CookieContainer = cookie;
}
return request;
}
}
我正在使用这个类来登录网页,它的工作正常。我想获取cookie值并在GUI中显示它。我从浏览器获得的Cookie值是
PHPSESSID = 8m3vbs6bpt8utj7st64qe9nvd5;安全=低
然而,当我在程序中请求cookie时;
client.ResponseHeaders["Set-Cookie"];
返回“security = low”
我如何获得PHPSESSID?提前致谢