|
ASP Cookies are used to store information specific to a visitor of your website. This cookie is stored to the user's computer for an extended amount of time. You can set cookie expiration date/time while creating a cookie.
Creating a cookie in ASP
"Response.Cookies" is used to create cookies. Here is the syntax and example.
<%
Response.Cookies("username")="Vinda"
%>
You can set a date when the cookie will expire:
<%
Response.Cookies("username")="Vinda"
Response.Cookies("username").Expires=#January 15,2011#
%>
Retrieving cookies in ASP
we can retrieve the value of the cookie by using Request.Cookies command.
<%
username=Request.Cookies("username")
response.write("username=" &username)
%>
ASP Cookie Arrays
Cookie arrays can contain a collection of multiple values. It is also known as Cookie with Keys.
<%
Response.Cookies("user")("name")="Vinda"
Response.Cookies("user")("level")="Editor"
Response.Cookies("user")("country")="India"
%> |