Cookies Property

Applies To   See Also   Examples  

Sets a cookie's name, path, value and expiry date. (Cookie Collection, Read/Write.)

Syntax (VBScript)

Response.Cookies(CookieName)(Key).Property = Value

Syntax (JavaScript)

Response.Cookies.Item(CookieName).SubItem(Key).Property = Value

It is recommended that you use the helper_js.csp file for cross-platform compatibility. See Some key functions in helper_js.csp for more information.

Parts

CookieName

Optional string for the name of the cookie you wish to access. If you do not include this you will access one of the properties listed in the Cookie Collection Properties.

Key

If this optional string is specified the cookie becomes a dictionary. See Remarks.

Property

Optional name of the property you wish to access. Note that this is not a variable. It may be one of the properties listed in Cookie Properties.

Value

The value of the cookies property.

Remarks

The Property part of the Cookies property is optional, if you do not include it the cookies Value property is accessed by default. If you do not include a cookie name or a cookie key then the Cookie Collection Properties is accessed. Note the following regarding keys and cookies.

If you write a cookie with a name and key as such:

Response.Cookies("MyDog")("ThePoodle") = "Fluffy"
Response.Cookies("MyDog")("TheBoxer") = "Iggy"

If you now proceed to set the cookie using simply the name you will lose the names of both different cookies set using the key. That is the following statement will erase any other values written to the cookie.

Response.Cookies("MyDog") = "Fido"

You will now be unable to retrieve the value of either:

A client can only store of a maximum of 20 cookies per server or domain with a maximum size of 4KB per cookie.

Cookie Properties

Property Description

Expires

The date that the cookie expires. (Date, Read-Only)

Name

The name of the cookie. (String, Read/Write)

Path

The path of the cookie. If this is not set, the application path is used. (String, Read-Only)

Value

The value of the cookie. (String, Read/Write)

Cookie Collection Properties

Property Description

Count

The number of cookies for this session. (Long, Read-Only)

Item

A cookie in the collection. Access using Collection.Item(CookieName). See above. (Cookie, Read/Write)

Example

There is an additional example in the Cookies Property under the Request Object.



Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com