[thelist] JS: Cookie Madness

Tom Dell'Aringa pixelmech at yahoo.com
Tue Feb 3 15:59:56 CST 2004


--- liorean <liorean at f2o.org> wrote:
> As I said, the document.cookie property is a semicolon separated 
> name/value list. It does not contain the expiry date (or the path
> or the domain for that matter) and there is no way you can read it 
> through regular JavaScript embedded in a document.

So to be clear, you are saying the document.cookie property holds
thus:

name1=value1
name2=value2
name3=value3

And that the expiry date, path and domain aren't accessible via JS.
In other words, the expiry date is for the WHOLE cookie, regardless
of how many name/value pairs are there? 

- or - 

there really is only ONE name/value pair per cookie? (looking at my
yahoo cookies, that seems to be the case which is why they set 4
cookies probably) and when you retrieve the cookie, you should ONLY
get the name/value pair and not the rest of the info?

It seems the second one is correct. Having said all that, I still
need to be able to SET my expiry date, yet my posted line won't do it
since it thinks the ; is the end of the statement.

document.cookie = cookieName + "=" + escape(cookieValue) + ";
expires=" + expireDate.toGMTString() + "; path=/;";

Even though your function was much terser, you seemed to follow the
same convention (albeit without whitespace). Can I set the expiry
date AFTER I set the value? 

Tom

=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life

[Those who say that I am finished, and am through, will have to run over my dead body to beat me...]


More information about the thelist mailing list