W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2007

[whatwg] Suggestion: API for accessing cookies (document.cookies)

From: Christian Schmidt <whatwg.org@chsc.dk>
Date: Fri, 28 Dec 2007 18:13:38 +0100
Message-ID: <47752EC2.409@chsc.dk>
In order to read, write and delete cookies from script most people use 
their own utility functions like the ones shown at 

It would be useful if cookies could be read, written and deleted through 
a more abstract API, e.g. by an HTMLCollection-like interface stored in 
document.cookies. This would allow something like this:

if (document.cookies.myCookie) {

	// or alternatively

	document.cookies.add('myCookie2', 'myVal', '/', 'example.org');

In particular the remove() method would be useful, because today neither 
the client-side nor the server-side can determine the path and domain 
parameters necessary to delete a given cookie unless they know how it 
was originally set.

The API could give access to the values only or possibly also to the 
other properties (expiry, path etc.) that are currenly not accessible 
from neither client-side nor server-side.

What do you think of this?

Christian Schmidt
Received on Friday, 28 December 2007 09:13:38 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:59 UTC