ASP Create/Set Cookies

Keep track of these sneaky users

One of the most basic uses of ASP is to set and retrieve cookie information for users visiting your site. Setting cookies and reading them once they are set is quite simple, as I will show you below.

Setting Cookies

Response.Cookies("UserName")="Louis Rofrano"

You can set cookies that contains multiple values

Response.Cookies("UserInfo")("FirstName")="Louis"
Response.Cookies("UserInfo")("LastName")="Rofrano"

Retrieving Cookies

Response.Write(Request.Cookies("UserName"))

Response.Write(Request.Cookies("UserInfo")("FirstName"))
Response.Write(Request.Cookies("UserInfo")("LastName"))

That's all that there is to it! Now you know enough to set cookies to track your users and allow them to log in to your site to access information specifically for them.

ASP

Ads