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

javascript - Will http_only cookies be sent with AJAX? - Stack Overflow

programmeradmin2浏览0评论

I found this link

But at the bottom it says This information is likely no longer up to date. So my question is, will http_only cookies be sent with AJAX? Can the response via AJAX set http_only cookies?

Edit 1: Let's say an user logged in to the system. His session started and http_only cookie is set. He tries to fetch list of his friends via AJAX and sends JSON. When making the AJAX request, do I need to make anything special to say to send cookies or not? Will each request send the cookies to the server by default? Will the response send back cookies (let's say I am updating users' time for last activity)?

I found this link

But at the bottom it says This information is likely no longer up to date. So my question is, will http_only cookies be sent with AJAX? Can the response via AJAX set http_only cookies?

Edit 1: Let's say an user logged in to the system. His session started and http_only cookie is set. He tries to fetch list of his friends via AJAX and sends JSON. When making the AJAX request, do I need to make anything special to say to send cookies or not? Will each request send the cookies to the server by default? Will the response send back cookies (let's say I am updating users' time for last activity)?

Share Improve this question edited May 23, 2017 at 10:31 CommunityBot 11 silver badge asked Dec 14, 2014 at 17:12 Ezio_Ezio_ 5933 gold badges11 silver badges24 bronze badges 1
  • you need to set the withCredentials option. – Daniel A. White Commented Dec 14, 2014 at 18:18
Add a ment  | 

1 Answer 1

Reset to default 8

Yes, they will.

The HttpOnly makes cookies not appear in document.cookie and XMLHTTPRequest.getAllResponseHeaders. It doesn't prevent them from being sent with HTTP requests, with the exception of cross-domain HTTP requests (which it doesn't sound like you're using here).

发布评论

评论列表(0)

  1. 暂无评论