Skip to main content
Module

x/cav/mod.ts>Cookie

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

Cav's cookie interface. This interface provides synchronous access to cookie values. The actual signing of signed cookies needs to be asynchronous, however. Once you are done accessing and modifying the cookie, you need to call the async "flush()" to sync cookie updates to the response headers that were provided when the cookie was initialized.

Properties

readonly
original: { readonly [x: string]: string; }

The original cookie keys and values, before modifications were made.

Methods

get(name: string, opt?: { signed?: boolean; }): string | undefined

Gets an optionally signed cookie value by its key name.

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

Sets a cookie value using the Deno std http module's cookie options. To accomadate signed cookies, the options type is extended to include the "signed" flag.

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

Unsets a cookie value by key. Path and domain can be specified to limit how the cookie is deleted. When deleting cookies for paths/domains that don't match the request URL, the cookie value will not be removed from the cookie object but the set-cookie header will still be sent on the response.

signed(): [string, string][]

Returns the signed cookie entries as an array.

unsigned(): [string, string][]

Returns the unsigned cookie entries as an array.

flush(): Promise<void>

Flushes cookie updates to the response headers that were baked into the cookie.