Cookie class is used to manage cookies : Stream Writer « File Directory « VB.Net






Cookie class is used to manage cookies

 

Imports System.Net
Imports System

Public Class CookieExample

    Public Shared Sub Main(args() As String)
        Dim request As HttpWebRequest = CType(WebRequest.Create("http://google.com"), HttpWebRequest)
        request.CookieContainer = New CookieContainer()

        Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
        Dim cook As Cookie
        For Each cook In  response.Cookies
            Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
            Console.WriteLine("Domain: {0}", cook.Domain)
            Console.WriteLine("Path: {0}", cook.Path)
            Console.WriteLine("Port: {0}", cook.Port)
            Console.WriteLine("Secure: {0}", cook.Secure)

            Console.WriteLine("When issued: {0}", cook.TimeStamp)
            Console.WriteLine("Expires: {0} (expired? {1})", cook.Expires, cook.Expired)
            Console.WriteLine("Don't save: {0}", cook.Discard)
            Console.WriteLine("Comment: {0}", cook.Comment)
            Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
            Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1, "2109", "2965"))

            Console.WriteLine("String: {0}", cook.ToString())
        Next cook
    End Sub 
End Class 

   
  








Related examples in the same category

1.StreamWriter WriteLine
2.StreamWriter Implements a TextWriter for writing characters to a stream in a particular encoding.
3.StreamWriter.Write (Char[], Int32, Int32) writes a subarray of characters to the stream.
4.Cookie.Comment Property gets or sets a comment that the server can add to a Cookie.
5.StreamReader.CurrentEncoding Property gets character encoding
6.StreamReader.Peek Method Returns the next available character but does not consume it.
7.StreamReader.ReadLine Method reads a line of characters from the current stream
8.StreamReader.ReadToEnd reads stream from the current position to the end
9.Create StreamWriter from file name string
10.Create StreamWriter from FileStream
11.Create StreamWriter from FileStream and default encoding
12.New StreamWriter("FileName", True)
13.Create FileStream from file name string
14.Create StreamWriter with Encoding UTF8
15.Create StreamWriter with Encoding UTF8 and buffer size
16.Writes a subarray of characters to the stream with StreamWriter
17.Creates a StreamWriter and write text to it
18.Flush data to StreamWriter
19.Write Unicode char with StreamWriter
20.StreamWriter Class Implements a TextWriter for writing characters to a stream in a particular encoding.
21.File.AppendText Method Creates a StreamWriter and appends UTF-8 encoded text to the file.
22.Use StreamWriter to write text to a file