Brandon
Brandon

Reputation: 1875

Is it possible to make an ajax request without sending/receiving a cookie?

I have a race condition where I send two ajax requests to my server, and one alters the session. Is it possible to make the second request not clobber the cookie that is returned from the first request? I am trying to avoid being forced to go to a series execution, as that seems like a bug which is just waiting to pop up again. I would rather keep them running in parallel if at all possible.

Upvotes: 0

Views: 44

Answers (1)

In general, it is indeed possible (but perhaps unsecure) to make an AJAX request without cookies. It might not be advisable.

(I don't know if your AXIOS toolkit permits that; but that becomes a different question)

Perhaps your session cookie should just contain a fixed opaque id (used server-side) that should never change. That is, the state would be kept and mutated server side only. You could send extra data in POST requests (with <input type='hidden' elements in HTML, or with AJAX).

Upvotes: 2

Related Questions