PHP cannot read a cookie set by Javascript

Javascript:

document.cookie = "name=value0;";

fetch("/path/to/file.php", {
      method: "POST",
      credentials: "same-origin",
      body: JSON.stringify({
        value1: value1,
        value2: value2
      }),
      headers: {
        "Content-Type": "application/json"
      },
    });

PHP:

var_dump($_COOKIE);

PHP response:

array(0) {
}

I have the PHP file in a seperate folder from the Javascript file, but they are on the same domain. When I set the cookie in Javascript, I use fetch to call the PHP file, but when it calls, there is no cookies that PHP can see. In the network console I can see that the script is being ran successfully.