-
Syntax:
- Response.Cookies(Name)[(Key)|.Attribute]=Value
- Name
- The Name argument is the name of the cookie.
- Value
- The Value argument specifies the value to assign to the key or attribute.
- Attribute
- The optional Attribute argument can one of the five following parameters:
Domain is write-only and allows pages on a domain made up of more than one server to share cookie information.
Expires is write-only and is the date on which the cookie expires.
Unless a date is specified, the cookie will expire when the session ends.
If a date is specified, the cookie will be stored on the client's disk after the session ends.
HasKeys is read-only and uses Boolean values to specify whether the cookie contains keys.
Path is write-only and if set, the cookie is sent by this path.
If this argument is not set, the default is the application path.
Secure is write-only and indicates if the cookie is secure.
- Key
- The optional Key argument specifies the Key to which the Value is assigned.
The Cookies collection property allows you to add a cookie to a browser and add values to the cookie.
The Cookies collection property assignes a new value to a cookie, if it exists;
otherwise, the cookie is created and the value is assigned.
There are two mandatory arguments and two optional arguments.
Examples
Code:
<%
Response.Cookies("myProduct")("Main") = "DevSite"
Response.Cookies("myProduct")("Prd1") = "ASP"
Response.Cookies("myProduct")("Prd2") = "VBScript"
Response.Write Request.Cookies("myProduct")
%>
Output:
PRD2=VBScript&PRD1=ASP&MAIN=DevSite