Tuesday, March 9, 2010

Week 4

Last week we worked with cookies and how they affect the web application. Cookies are small text files that attach to the users browser to store session and user data. We use cookies so the browser recognises the user upon frequent visits to the web app. To determine when the cookie expires, we use the following code:

Response.Cookies("userinfo").Expires = DateTime.Now.AddDays(7)

The Response object allows us to add the cookie to the browser.
To remove a cookie we simply put the expiry date to a day in the past

Response.Cookies("userinfo").Expires = DateTime.Now.AddDays(-7)

No comments:

Post a Comment