cookiecookie*
*Contents  *Index  *Topic Contents
*Previous Topic: content
*Next Topic: cookieEnabled

cookie

Description

Specifies a string value of a cookie, which is a small piece of information stored by the browser.

Cookies are made from the following. (All are optional with the exception of the name=value pair.) Arguments are separated by semicolons.

name=value; Each cookie is stored in a name=value pair, that is, if the cookie is "foo" and you want to save foo's value as "bar", the cookie would be saved as foo=bar. You can save as many name=value pairs in the cookie as you want, but the cookie is always returned as a string of all the cookies that apply to the page, so the string that is returned has to be parsed to find the values of individual cookies.
Expires=date; If no expiration is set on a cookie, it will expire when the browser is closed. Setting an expiration date in the future causes the cookie to be saved across browser sessions. Setting an expiration date in the past will delete a cookie. The date should be specified using GMT format.
domain=domainname; The domain of the cookie can be set, which allows pages on a domain made up of more than one server to share cookie information.
path=path; Setting a path for the cookie will allow the current document to share cookie information with other pages within the same domain, that is, if the path is set to /foobar, all pages in /foobar and all pages in subfolders of /foobar will be able to access the same cookie information.
secure;Specifying a cookie as "secure" means that the stored cookie information can be accessed only from a secure environment.

Syntax

object.cookie[ = cookie]

Remarks

Use string methods such as substring, charAt, indexOf, and lastIndexOf to determine the value stored in the cookie.

This property has read-write permissions, meaning you can change as well as retrieve its current value.

Applies To

document


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.