ASP   «Prev  

User Specific Information using Cookie Attributes

What is a Cookie?


How to Create a Cookie?

The "Response.Cookies" command is used to create cookies.
Note: The Response.Cookies command must appear BEFORE the <html> tag. In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:

< %
 Response.Cookies("firstname")="Alex"
 %>
 

It is also possible to assign properties to a cookie, like setting a date when the cookie should expire:
< %
 Response.Cookies("firstname")="Alex"
 Response.Cookies("firstname").Expires=#May 10,2012#
 %>
 

How to Retrieve a Cookie Value?


< %
 fname=Request.Cookies("firstname")
 response.write("Firstname=" & fname)
%>

Cookie attributes