Send cookie to server?

M

Martin

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?
 
D

David Dorward

Martin said:
How can I send a cookie (that was created by client-side scripting) to
the server?

Issue any old http request, the browser will handle it automatically.
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?

A cookie, is a cookie, is a cookie. It doesn't matter how it was created.
 
M

Martin

Issue any old http request, the browser will handle it automatically.


A cookie, is a cookie, is a cookie. It doesn't matter how it was created.

David:

Thank you, thank you, thank you. I have struggled with this for
several hours. It never dawned on me to simply check the cookies
collection on the server to see what was coming in.

Now, please educate me about something: how does the browser know
which cookies to send? Is it going to be sending those
client-side-created-cookies to every server that the user goes to from
now on?

Martin
 
B

Benjamin Niemann

Martin said:
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'
 
D

David Dorward

Martin said:
Now, please educate me about something: how does the browser know
which cookies to send? Is it going to be sending those
client-side-created-cookies to every server that the user goes to from
now on?

Cookies are host name specific (although I believe there are means to state
that they can be used on multiple hosts in the same domain).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top