I am writing a single-page application with CanJS. For one of models, every time I save a new item, the application sends the normal POST
request. However, there is a specific cookie that is returned in the HTTP
response that I would like to send back to the server on GET
requests when fetching an item.
I am writing a single-page application with CanJS. For one of models, every time I save a new item, the application sends the normal POST
request. However, there is a specific cookie that is returned in the HTTP
response that I would like to send back to the server on GET
requests when fetching an item.
- I'm pretty sure any request should send cookies automatically – Explosion Pills Commented Dec 5, 2012 at 7:56
- @ExplosionPills I thought so, too, but, for some reason, the cookie is not being sent. I looked at the headers. – jonathanmarvens Commented Dec 5, 2012 at 8:05
1 Answer
Reset to default 1All cookies specific to an application are passed automatically to server in request header. Make sure that the cookie which you want to send is of the same application.
This you can check by looking into the cookies of your browser. Make sure that the cookie which you want to send has Domain as your application name. Like all stackoverflow cookie will have domain value as .stackoverflow.
You can refer to this tutorial which talks about creation and setting of cookie in JavaScript : http://www.w3schools./js/js_cookies.asp