What if the js local setting cookie is invalid? (under the chorme browser, a local service is set up with node)

1. At the beginning, the service is not started and the code on cookie is directly set with js:

var _json = {
    username: "ming"
} 
var _cookies = "";
_json["domain"] = document.domain;
_json["max-age"] = 60*60*24*90;
_json["path"] = "/";
for(var key in _json){
    _cookies += key + "=" + _json[key]+";";
}
document.cookie = _cookies;

did not set successfully

  1. searched and said that chorme must have a service to set up, so a node service was set up to access a page and set up cookie, but still did not succeed. The node service is a basic web access service
.

hoping that experienced friends can help generously, I have searched for a long time and tried all kinds of methods to solve the problem. It may be that the service mode is wrong or for other reasons, I do not have the ability to find and advise

Mar.20,2021

I just tried it on the chrome console. Can you set cookie with this js code?

clipboard.png


npm install-- save js-cookie

Menu