最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Pass cookie back to the server - Stack Overflow

programmeradmin2浏览0评论

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.

Share Improve this question edited Sep 22, 2014 at 0:07 ramblinjan 6,6944 gold badges31 silver badges41 bronze badges asked Dec 5, 2012 at 7:31 jonathanmarvensjonathanmarvens 4021 gold badge3 silver badges10 bronze badges 2
  • 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
Add a ment  | 

1 Answer 1

Reset to default 1

All 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

发布评论

评论列表(0)

  1. 暂无评论