Prevent Cookies From Being Sent on AJAX Request

前端 未结 5 1214
庸人自扰
庸人自扰 2021-02-05 00:58

I have a web service that I invoke from script but that does not need any information stored in cookies. Anytime I make a request to the service, the cookie is sent along with i

5条回答
  •  悲哀的现实
    2021-02-05 01:10

    The withCredentials flag is needed to actually send cookies with cross-origin ajax calls.

    See: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

    Setting it to false will prevent cookies from being sent.

    With same-origin requests you will need to follow the other answers mentioned here.

提交回复
热议问题