Help > Web Development > Reference > Scripting Objects > Request Object > Cookies Collection

Request.Cookies Collection

The cookies collection enables you to gain access to the cookies sent with the HTTP request.

Cookies are small amounts of information that are sent around with each HTTP request to the server.  A cookie allows you to keep some state information about the user that is re-transmitted each time the user accesses the website.  Note that cookies are sent in clear-text and should not be used to store password or any other sensitive data.

Properties
Count Returns the number of cookies sent this request.
Item(name or index) Returns the cookie with the given name or index.
Key(index) Returns the name of the cookie at the given index.

Remarks
If the item requested does not exist in the collection Perceptive Enterprise Search will return Empty.

You can access a cookie without specifying the Item property by calling Request.Cookie(variablename). 


Cookie Object

The cookie object represents a single cookie sent with the HTTP request.  A single cookie can include one or more values as long as the total length does not exceed 250 characters.

Properties

Count Returns the number of cookies sent this request.
HasKeys Returns boolean value indicating if the current cookie has more than one value, i.e. it uses name/value pairs.
Item(empty or name or index) Returns the cookie with the given name or index.
Key(index) Returns the name of the cookie at the given index.

Remarks

Perceptive Enterprise Search supports multiple keyed or single keyed cookies.  A multiple key cookie stores the key/value pairs in the following format:

first=valuea&second=valueb&third=valuec 

To fetch any of the keyed values use the following script:

<%= Request.Cookies("MyCookie")("first") %>
To fetch the single keyed cookie value, or the multiple key cookie as a single value, use the following:

<%= Request.Cookies("MyCookie") %>
You can iterate through all cookie keys in the request using the following:

For Each Cookie in Request.Cookies
  Response.Write Cookie
Next
To iterate through all keys within a single cookie use the following: 
For Each Cookie in Request.Cookies("MyCookie")
  Response.Write Cookie
Next
Applies To
Request Object