HTTP Cookies and Ajax requests over HTTPS

后端 未结 2 581
南笙
南笙 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:08

    Ok, found the solution to the cookie problem.

    See XHR specs, jQuery docs and StackOverflow.

    The solution to have the cookies sent when switching protocol and/or subdomain is to set the withCredentials property to true.

    E.g. (using jQuery)

     $.ajax( {
       /* Setup the call */
       xhrFields: {
         withCredentials: true
       }
     });
    

提交回复
热议问题