Write Cookies to Browser

A great way of personalizing your website for users is through the use of browser cookies.  There are many different uses for cookies.  For example, it is common to write a cookie to the user’s browser when they login to your website.  This script shows you how to write a basic cookie to the browser.

Response.Cookies("MyCookie")("Domain") = "www.YourDomainHere.com"
Response.Cookies("MyCookie")("UserType") = "Member"
Response.Cookies("MyCookie")("Expires") = Date() + 30

This cookie defines your website Domain, identifies the user as a Member, and sets the cookie to Expire in 30 days.  There you have it, now you can write cookies to a browser.  So what happens next?  After you write a cookie to the browser, you will need to read the cookie when the user returns, right?  Check out Read Cookies from Browser to learn how.

< Back to ASP Scripts