Skip to main content
Latest
class CookieJar
extends Map<string, string>
import { CookieJar } from "https://deno.land/x/cookies@1.0.0/mod.ts";

Cookie manager for Deno built on top of the Map built-in collection

Constructors

new
CookieJar()

Methods

private
setCookie(
name: string,
value: string | null | undefined,
): boolean

Sets a cookie in the response header,

clear(): void

Clears all the set cookies. Will not guarantee all cookies to be deleted, as some might have special parameters set. If this is the case use the delete method with same value in the parameters: path, domain, secure, httpOnly, sameSite.

delete(name: string, opts?: Exclude<CookieOptions, "expires" | "maxAge" | "overwrite">): boolean

Deletes a specific cookie. Will not guarantee all cookies to be deleted, as some might have special parameters set. If this is the case use the delete method with same value in the parameters: path, domain, secure, httpOnly, sameSite.

get(name: string, opts?: Pick<CookieOptions, "signed">): string | undefined

Gets a cookie, Only sets cookie if overwrite is false or doesn't already exist

set(
name: string,
value: any,
options?: CookieOptions,
): this

Sets a new cookie, if value is empty and there are no options the delete method is used instead. If any parameter is invalid it will throw a TypeError