deleteCookie

import { deleteCookie } from "jsr:@ende/http";

function

function deleteCookie(headers: Headers, name: string, attributes?: Pick<Cookie, "path" | "domain" | "secure" | "httpOnly" | "partitioned">): void

Set the cookie header with empty value in the headers to delete it.

The attributes (path, domain, secure, httpOnly, partitioned) need to match the values when the cookie was set.

Note: Deleting a Cookie will set its expiration date before now. Forcing the browser to delete it.

headers: Headers

The headers instance to delete the cookie from

name: string

Name of cookie

attributes?: Pick<Cookie, "path" | "domain" | "secure" | "httpOnly" | "partitioned">

Additional cookie attributes

Example: Usage

import { deleteCookie } from "@ende/http/cookie";
import { assertEquals } from "@ende/assert";

const headers = new Headers();
deleteCookie(headers, "deno");

const cookieHeader = headers.get("set-cookie");

assertEquals(cookieHeader, "deno=; Expires=Thu, 01 Jan 1970 00:00:00 GMT");

Source