Please see the code below:
CookieContainer cookieJar = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
request.CookieContainer = cookieJar;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
int cookieCount = cookieJar.Count;
How can I get cookies info inside cookieJar? (All of them, not just for a specific domain.)
And how can I add or remove a cookie from that?
reflection can be used to get the private field that holds all the domain key in CookieContainer object,
Q. How do i got the name of that private field ?
Ans. Using Reflector;
its is declared as :
once we get the private field, we will get the the domain key, then getting cookies is a simple iteration.