S
S
source20032016-11-09 17:58:58
JavaScript
source2003, 2016-11-09 17:58:58

How to send cookies along with ajax request?

There is a site on which you need to simulate a user action, and if I am authorized on this site, then the POST request from the console is successful, although the session data, etc., is in the request itself. are not transmitted. I tried to send this request anonymously and it did not go through, it is obvious that the matter is in sessions (cookies that store the session id on the server).

I know the value of the session ID, now it remains to send an anonymous request and, together with the request, send a cookie that will contain the session ID. I just don't understand how to do this, I hope you tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
source2003, 2016-11-09
@source2003

beforeSend: function(xhr) {
xhr.setRequestHeader("Cookie", 'PHPSESSID=klkva1mj4jlric8v9httbvvdf7'); 
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question