What can cause a cookie not to be set on the client?

后端 未结 3 867
抹茶落季
抹茶落季 2020-12-15 23:12

I have a web application that uses jQuery.ajax to perform a request to another host (right now actually the same because I\'m using different ports of \"localhost\"). The se

3条回答
  •  清酒与你
    2020-12-15 23:52

    After struggling with a similar scenario (no CORS) for hours, I found out another potential reason: be sure to explicitly set the path for the cookie.

    My front-end app was making a call to HOST_URL/api/members/login, and this was returning the right Set-Cookie header, with no path.

    I could see the cookie under Response Cookies in Chrome DevTools, but subsequent requests were not including it. Went to chrome://settings/cookies, and the cookie was there, but the path was /api/members.

    Specifying root path when setting the cookie at server-side fixed the issue.

提交回复
热议问题