3

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 take the incoming xmlHTTPRequest variable that is set and modify the headers to remove the cookie object that is in there, so in the call to my web service, it does not renew forms authentication in asp.net

lslow00
  • 125
  • 1
  • 4

1 Answers1

0

Try

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

EDIT: It appears this does not work, at least not consistently. Read Cookie Monster For XMLHttpRequest

You could also use the jQuery cookie plugin to delete cookies.

$.cookie("nameOfCookie", null);
Adam
  • 43,763
  • 16
  • 104
  • 144
  • I've got another crappy error. Now that i've removed the cookie, the ajax call is returning an error stating 12150, Unknown as the status, statustext. I need to access the web service free of cookies so that i can not have the asp.net authentication renewed or the session renewed. – lslow00 Jun 23 '10 at 18:50
  • 2
    This does not remove the cookies. See http://www.michael-noll.com/tutorials/cookie-monster-for-xmlhttprequest/ – Daniel Dec 13 '10 at 19:07