Create Cookies using VB.NET

In this article I will show you how to create cookies and display its properties in VB.NET.
  • 4903

Creating Cookies in VB.NET is  very simple and straight forward. A Cookie is a small text file that the browser creates and stores on the hard drive of your machine. Cookie is just one or more pieces of information stored as text strings. A Web server sends you a cookie and the browser stores it. The browser then returns the cookie to the server the next time the page is referenced. The most common use of a cookie is to store information about the user and preferences the  the user makes. Lets see below how we create a cookie and display its properties also:

Imports System.Net
Imports System.Net.Sockets
Public Class Tester
    Public Shared Sub Main()
        Dim cookie As System.Net.Cookie = New Cookie("HASH", "", "/", "")
        Console.WriteLine("Comment: " & cookie.Comment.ToString)
        Console.WriteLine("Domain: " & cookie.Domain.ToString)
        Console.WriteLine("Expired: " & cookie.Expired.ToString)
        Console.WriteLine("Expires: " & cookie.Expires.ToString)
        Console.WriteLine("Name: " & cookie.Name.ToString)
        Console.WriteLine("Path: " & cookie.Path.ToString)
        Console.WriteLine("Port: " & cookie.Port.ToString)
        Console.WriteLine("Secure: " & cookie.Secure.ToString)
        Console.WriteLine("Value: " & cookie.Value.ToString)
        Console.WriteLine("Version: " & cookie.Version.ToString)
    End Sub
End Class



I hope the above code snippet helps you to create cookies using VB.NET.


More Articles

© 2020 DotNetHeaven. All rights reserved.