Assign cookies in GET order with XMLHttpRequest

2

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

My code is as follows:

var pedido = new XMLHttpRequest()
pedido.open("GET","https://www.google.com/complete/search")
pedido.setRequestHeader("Cookie","SSID=AbhcxIM8JMu")

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
source

1 answer

2

Creating a cookie in JS is very simple:

document.cookie='SSID=AbhcxIM8JMu';

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
source