Why is the browser not setting cookies after an AJAX request returns?

前端 未结 5 1508
走了就别回头了
走了就别回头了 2020-11-29 00:35

I am making an ajax request using $.ajax. The response has the Set-Cookie header set (I\'ve verified this in the Chrome dev tools). However, the browser does

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 01:19

    If you're using the new fetch API, you can try including credentials:

    fetch('/users', {
      credentials: 'same-origin'
    })
    

    That's what fixed it for me.

    In particular, using the polyfill: https://github.com/github/fetch#sending-cookies

提交回复
热议问题