Examine Cookies : Cookie : Network C# Examples


C# Examples » Network » Cookie »

 

Examine Cookies









    
using  System;  
using  System.Net;  
  
class  MainClass  {    
    public  static  void  Main(string[]  args)  {  
  
        HttpWebRequest  req  =  (HttpWebRequest)  WebRequest.Create("http://www.google.com");    
  
        req.CookieContainer  =  new  CookieContainer();  
  
        HttpWebResponse  resp  =  (HttpWebResponse)  req.GetResponse();  
  
        Console.WriteLine("Number  of  cookies:  "  +  resp.Cookies.Count);  
        Console.WriteLine("{0,-20}{1}",  "Name",  "Value");  
  
        for(int  i=0;  i  <  resp.Cookies.Count;  i++)  
            Console.WriteLine("{0,  -20}{1}",  
                                                  resp.Cookies[i].Name,  
                                                  resp.Cookies[i].Value);  
  
        resp.Close();  
    }  
}
    
   
  
   



Output

Number of cookies: 1
Name                Value
PREF                ID=36223fb0ac52c150:TM=1174856804:LM=1174856804:S=N9zHU5qFxjy-nbPF


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» Cookie