Aerovistae Aerovistae - 1 year ago 56
Javascript Question

Are HTTP headers handled automatically by the browser in AJAX responses?

Here's my situation: I make an ajax post to a server endpoint, and it sends me back some JSON data in response. This JSON response also includes the


Does the cookie get set automatically when it's in a response to an ajax request, or do I have to read it out of the headers and do it manually?

(As opposed to the headers being present on the response to a form submit, where I know the browser will be handling the response and its headers on its own, no JS necessarily involved.)

Answer Source

Yes, it gets set automatically. An AJAX request is just an HTTP request. You can send Cookie headers, and receive Set-Cookie Headers normally.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download