Using Cookies for Saving Information

Cookies are pieces of information that a user’s browser can hold and that can have a maximum size of 4 Kbytes. Each time the browser opens your web application, it recalls all cookies provided by the website. The following are examples of writing and reading cookies:

 'Write a cookieDim aCookie As New HttpCookie("MyCookie")aCookie.Value = "Information to store"aCookie.Expires = New DateTime(10, 10, 2010)Response.Cookies.Add(aCookie) 'Read a cookieDim getCookie As HttpCookie = Request.Cookies("MyCookie")Dim cookieVale As String = getCookie.Value

Notice that the Expires property of type Date is required to specify that the cookie information will no longer be valid after that date, ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.