What should I do if I use the ajax post form and return the response setting cookie to fail?

  node.js, question

After many experiments, there is a Set-Cookie in the response returned, but there is still no cookie when the home page is refreshed.
The following is the submit request code:

javascript$.post("/api/register",{
 name : name,
 email : email,
 Passwd: CryptoJS.SHA1(email plus':' plus password).toString (),
 },function(data, textStatus, xhr){
 if(data === "success create"){
 location.assign('/');
 }else{
 showError(data);
 bracket
 });

The problem was found, and the browser refused to store the cookie because I did not set path when setting the cookie.