Cookie expires (Attribute)

An attribute that defines the expiry date and time of a cookie.

The lifetime of a cookie is defined with this attribute. From JavaScript, you can set this attribute but you cannot read it since there is no real object model for the cookies.

To define this attribute, you add a name-value pair to the cookie definition string whose name is "expires" and whose value is defined according to the Date.toGMTString() method.

A cookie only survives for the duration of the page in the browser unless you define an expiry date for it. If the expiry date is in the future when the browser exits, they will be remembered in a persistent cache inside the browser. If not, the cookie is discarded and unavailable next time you run the browser.

See also:Date.toGMTString()