I'm writing a chrome extension that uses AJAX to talk to a server. I want to read the KEY
in set-cookie
from AJAX response, but I cannot find a way to do this.
I have tried document.cookie
and xhr.getAllResponseHeaders()
$.get(myURL,
function (output, status, xhr) {
console.log(document.cookie); //empty
console.log(xhr.getAllResponseHeaders());
//Only Connection and Content-Type shows
}
);
The raw response header is:
Connection:Close
Content-Type:text/html
Set-Cookie:KEY=DFDSFDCB; PATH=/;
I know that according to spec, getAllResponseHeaders()
is supposed to filter out set-cookie
field. Is there any workaround?