Posted by Benjamin Niemann on 03/31/06 22:01
Martin wrote:
> How can I send a cookie (that was created by client-side scripting) to
> the server?
>
> It's my understanding that if the cookie had been created by the
> server, it would be automatically submitted when a request is sent to
> that server. Is it possible to achieve this same behavior with a
> cookie that was not created by the server?
The cookie gets sent to the server (on subsequent requests), which sent the
document. You may have to specify the 'path' parameter (which defaults to
the directory of the document), if the document is in a subdirectory and
the cookie should be sent to documents in another directory. E.g. cookie
created in /foo/doc1 and /bar/doc2 should recieve it. By default only
documents in /foo will get the cookie.
If you want the cookie to be sent to a document on another domain, you also
have to specify the 'domain' parameter.
document.cookie = 'foobar=this is the value; path=/; domain=www.example.com'
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
[Back to original message]
|