user181548
user181548

Reputation:

Is an Ajax request guaranteed to send cookies?

I've just tested this and it seems that Ajax requests send the cookie header from the browser to the server each time. Is this a guaranteed behaviour which I can rely on, or is it something which may or may not happen?

Upvotes: 22

Views: 6175

Answers (2)

Mangu Singh Rajpurohit
Mangu Singh Rajpurohit

Reputation: 11420

Like other answer suggests, AJAX is a way to request service from server in an asynchronous way. However, internally HTTP protocol is used for AJAX too, which says that cookies if there any must be send with HTTP requests(sync or async). Thus, most of the modern browser adheres to it, otherwise it's regarded as bug in browser implementation.

Upvotes: 7

Zepplock
Zepplock

Reputation: 29135

Ajax is just a "way" to generate HTTP request. It is still a browser doing it so it will follow browser "rules". Can never be 100% sure but I would say yes.

Upvotes: 22

Related Questions