Cookies

When Chapter 3 looked at the Request object, you saw how cookies can be accessed on the server when a request is received from the browser. Cookies store information on the client machine, and are sent to the server with each request for information. The server can set or change the cookie’s values, and the Response object provides an interface for just this purpose. Like the Request object, it holds a cookies collection—but this time you can use it to write values to the cookies that are sent back with your page.

The following code adds a cookie named Name with the value of Rick. It gets the HttpCookieCollection by calling Response.Cookies. It creates an HttpCookie object named "Name" and sets its value to "Rick". Finally, the newly-created ...

Get Special Edition Using® Microsoft® ASP.NET 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.