How to send cookies with ajax request?

Is there a website on which you want to simulate a custom action, and if I logged on to this site, a POST request from the console is successful, although the query session data, etc. are not transmitted. Tried to send this request anonymously and it is not passed, obviously the case in the sessions (cookies that store the session id on the server).

The value of the session ID I know now to send an anonymous request and with the request send a cookie that will contain the session ID. That's just not understanding how to do it, I hope you tell me.
July 2nd 19 at 17:59
1 answer
July 2nd 19 at 18:01
beforeSend: function(xhr) {
xhr.setRequestHeader("Cookie", 'PHPSESSID=klkva1mj4jlric8v9httbvvdf7'); 

Find more questions by tags HTTP CookiesAJAXjQueryJavaScript