First of all, what are cookies? No, we're not talking about the sort you eat! Cookies are small pieces of information saved by the browser enabling websites to remember your preferences (good), login information (hmm...), or track your movements across the site (bad!).
Whatever your view on cookies, ASP provides full support for them, enabling you, the webdesigner, to make the most out of them if you so wish.
Note |
To save a value to a cookie, simply use this syntax:
Response.Cookies("CookieName") = Value
Once the cookie is saved, you can access it by using
Variable =
Request.Cookies("CookieName")
Note, however, that you cannot access the cookie from the same page you saved it on. So, for example,
Response.Cookies("username") = Request.Form("username")
Response.Write "hello " & Request.Cookies("username")
would not work! Of course, if you re-load the same page after the cookie has been saved, you will get access to that cookie.
Comments