Using Cookies

If you do not wish to store the state of your application on the Web server, you can send the state out to the client's browser. You do this by using cookies. You will most likely use a memory cookie because they are destroyed when users close their browsers. To create a memory cookie, you use the Cookies property of the Response object, as shown in the following code. In this example, the code creates a memory cookie named Email and assigns the e-mail address into the cookie:

Response.Cookies("Email").Value = "JohnDoe@yahoo.com"

Another method of creating a new cookie is to use the Add method of the Cookies collection, which is a property of the Response object. You can create a new System.Web.HttpCookie object and pass in the ...

Get ASP.NET Developer's JumpStart 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.