Skip to main content
Module

x/cav/mod.ts>CookieJar

A server framework for Deno
Go to Latest
interface CookieJar
Re-export
import { type CookieJar } from "https://deno.land/x/cav@0.0.24/mod.ts";

Interface for reading and updating the cookies for a Request. Supports cookie signing. Most operations are synchronous, with the exception of .setCookies().

Properties

get: (name: string) => string | undefined

Gets an up-to-date cookie value.

set: (
name: string,
value: string,
) => void

Updates a cookie's value. Cookies with the signed option set to true will be stored as a JWT with the header removed, signed using the keys provided when the CookieJar was created.

When both the maxAge and expires options are specified, only maxAge will be used; expires will be ignored.

delete: (name: string, opt?: CookieDeleteOptions) => void

Removes a cookie by clearing and expiring any previous value.

entries: () => [string, string][]

Returns an array of all cookie [name, value] pairs. Order: [...signed, ...unsigned]

has: (name: string) => boolean

Checks if a cookie exists in the CookieJar.

isSigned: (name: string) => boolean

Checks if a cookie is signed or not. Non-existent cookies return false.

setCookies: (headers: Headers) => Promise<void>

Calculates the set-cookie headers for all updates applied to this CookieJar and appends them to the given Headers instance. Note that this operation is asynchronous while the other CookieJar operations are synchronous.