CSRF-X Auth Library - v1.0.3
    Preparing search index...

    Function parseCookies

    • Extracts all cookies from a Response object's Set-Cookie headers.

      Parameters

      • headers: Headers

        The Headers object from a fetch Response.

      Returns Map<string, string>

      A Map where each key is a cookie name and the value is the cookie value.

      The function reads all Set-Cookie headers (using headers.getSetCookie()),
      parses each with parseSetCookie, and stores the name‑value pairs
      in a Map. Only the cookie name and value are captured; attributes like
      HttpOnly, Secure, Path, Expires, etc., are ignored.

      If headers.getSetCookie is not available (e.g., in some non‑standard environments),
      it falls back to an empty array, resulting in an empty Map.

      const response = await fetch('/login');
      const cookies = parseCookies(response.headers);
      console.log(cookies.get('sessionId')); // "abc123..."

      0.1.1