I'm not trying to send cookie data with the xmlhttprequest, rather I'm trying to use the xmlhttprequest to set cookies for the session without requiring user interaction.
The default is false . XMLHttpRequest responses from a different domain cannot set cookie values for their own domain unless withCredentials is set to true before making the request.
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent can send it back to the server later. To send multiple cookies, multiple Set-Cookie headers should be sent in the same response.
A regular cookie can be set server side or client side. The 'classic' cookie will be sent back with each request. A cookie that is set by the server, will be sent to the client in a response. The server only sends the cookie when it is explicitly set or changed, while the client sends the cookie on each request.
Also I would say it is perfectly acceptable to change or set a cookie in response for the GET request because you just return some data.
According to the spec:
If the user agent supports HTTP State Management it should persist, discard and send cookies (as received in the Set-Cookie and Set-Cookie2 response headers, and sent in the Cookie header) as applicable.
As far as I've managed to tell, Firefox 3.6 will store the cookies, but they won't be available to the document of the page which executed the query through document.cookie
. But they will be sent with subsequent XMXHttpRequests, which is sufficient for my uses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With