Assign cookies in GET order with XMLHttpRequest


I am trying to assign a cookie in a GET request, in an order XMLHttpRequest .

My code is as follows:

var pedido = new XMLHttpRequest()"GET","")

This throws me a warning in Firefox :


The request to establish a forbidden header was denied: Cookie

I suspect that the solution is to change something in the configuration of Firefox , but I do not know exactly how to do it.

Is it possible to do this in JavaScript ?

asked by ArtEze 21.09.2018 в 18:32

1 answer


Creating a cookie in JS is very simple:


You can find more information at MDN , but it does not really take much more: Once that you have defined a value, it will be automatically added to each request you make to the server to which the current page belongs.

answered by 21.09.2018 / 19:01