Delete cookie from XMLHttpRequest object

I am making an ajax call with jquery like:

$.ajax({
    url: "path/to/webservice.asmx"
    beforeSend: function(xmlHTTPRequest) {
        //modify headers here
        //remove cookies
    }
    success: function() {
        //do stuff 
   }
}

What I would like to do in the beforeSend function is to accept the input variable xmlHTTPRequest, which is set and changes the headers to remove the cookie that is there, so when I call my web service it does not update the authentication form in asp.net

+3
source share
1 answer

Try

xmlHTTPRequest.setRequestHeader("Cookie", "");

EDIT: It seems like this is not working, at least not sequentially. Read Cookie Monster for XMLHttpRequest

You can also use jQuery cookies to delete cookies.

$.cookie("nameOfCookie", null);
0

Source: https://habr.com/ru/post/1751417/


All Articles