ESP8266WebServer cookie save problem

I don't have an ESP8266, but ESPAsyncWebServer works on that and ESP32, and the usage is similar, with handler functions. The function receives the request as an argument, and you call methods on that. With their "simple_server" example, you can replace the handler for "/" with your code with just a few modifications

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    String storedCookieValue = "None";
    String newCookieValue = String(millis());

    if (request->hasHeader("Cookie")) {
      String cookie = request->header("Cookie");
      int pos = cookie.indexOf("clientID=");
      if (pos != -1) {
        pos += 9;  // Length of "clientID="
        int endPos = cookie.indexOf(";", pos);
        if (endPos == -1) endPos = cookie.length();
        storedCookieValue = cookie.substring(pos, endPos);
      }
    }

    // no such method -- equivalent one at the end, below
    // request->sendHeader("Set-Cookie", "clientID=" + newCookieValue + "; Path=/;");
    Serial.println("Stored Cookie: " + storedCookieValue);
    Serial.println("New Cookie: " + newCookieValue);

    String html = "<html>"
                  "<head>"
                  "<style>"
                  "body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; font-family: Arial, sans-serif; background-color: #f0f0f0; }"
                  "div { text-align: center; background: #fff; padding: 40px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }"
                  "h1 { font-size: 3em; margin-bottom: 20px; }"
                  "p { font-size: 1.5em; margin-bottom: 20px; }"
                  "</style>"
                  "</head>"
                  "<body>"
                  "<div>"
                  "<h1>Stored Cookie Value: " + storedCookieValue + "</h1>"
                  "<p>New Cookie Value: " + newCookieValue + "</p>"
                  "</div>"
                  "</body>"
                  "</html>";
    auto resp = request->beginResponse(200, "text/html", html);
    resp->addHeader("Set-Cookie", "clientID=" + newCookieValue + "; Path=/;");
    request->send(resp);
  });

Note the last three statements. It works for me.

Back to ESP8266WebServer: your usage of sendHeader before send looks right, based on their other examples. You can use a Network inspector in a desktop browser to see if the Set-Cookie header is coming across.

You could also try some other header to in case it's a more general problem. For example, this is how it implements redirect

  void redirect(const String& url, const String& content = emptyString) {
    sendHeader(F("Location"), url, true);
    sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
    sendHeader(F("Pragma"), F("no-cache"));
    sendHeader(F("Expires"), F("-1"));
    send(302, F("text/html"), content);  // send 302: "Found"
    if (content.isEmpty()) {
      // Empty content inhibits Content-length header so we have to close the socket ourselves.
      client().stop();  // Stop is needed because we sent no content length
    }
  }

so in your handler, you could have instead of send

  server.redirect("http://google.com/");