HTTP Cookies and Ajax requests over HTTPS

后端 未结 2 582
南笙
南笙 2020-11-30 18:40

I know this has been asked before in various forms, but I can\'t seem to get around the problem. I have tried using both jQuery and the native JS API to make the Ajax reque

2条回答
  •  甜味超标
    2020-11-30 19:09

    Document.cookie and Ajax Request does not share the cookie. Otherwise, ajax can't access the cookies from document.cookie or the response headers. They can only be controlled by the remote domain.

    If you first get response including cookie from server by ajax, Since that you can request ajax communication with cookie to server.

    For this case, you write such as below code (jQuery)

     $.ajax({
          xhrFields : {
               withCredentials : true
          }
     });
    

    See this article and demo

提交回复
热议问题