when the following two lines of code are executed under the browser
document.cookie="a=1";
document.cookie="b=2";
console.log(document.cookie) // a=1; b=2
copy the code
and execute the following statement under Node
document={cookie:""};
document.cookie="a=1";
document.cookie="b=2";
console.log(document.cookie) //b=2
copy code
this is why, why does the document.cookie assignment under the browser not overwrite the old value?
the problem comes from the crawler I did to a website. The JS code is confused every time the site is opened. In many places in the JS code, the document.cookie is assigned
, but I intend to move the JS to execute under Node, where there is no document object itself. Just initialize one directly, only to find that there is a problem with the assignment.