Skip to main content
Module

x/acorn/deps.ts>Cookies

A focused RESTful server framework for Deno 🌰🦕
Go to Latest
class Cookies
import { Cookies } from "https://deno.land/x/acorn@0.0.7/deps.ts";

Constructors

new
Cookies(
requestHeaders: Headers,
responseHeaders: Headers,
options?: CookiesOptions,
)

A class which provides an abstraction for getting and setting cookies in request and response headers.

This was heavily influenced by pillarjs/cookies.

Methods

delete(name: string, options?: CookiesSetDeleteOptions): boolean

Set a cookie to be deleted in the response. This is a convenience function for .set(name, null, options?).

entries(): AsyncIterableIterator<[string, string]>

Iterate over the request's cookies, yielding up a tuple containing the key and value of each cookie.

If a key ring was provided, only properly signed cookie keys and values are returned.

get(name: string, options?: CookiesGetOptions): Promise<string | undefined>

Get the value of a cookie from the request.

If the cookie is signed, and the signature is invalid, undefined will be returned and the cookie will be set to be deleted in the response. If the cookie is using an "old" key from the keyring, the cookie will be re-signed with the current key and be added to the response to be updated.

keys(): AsyncIterableIterator<string>

Iterate over the request's cookies, yielding up the key of each cookie.

If a keyring was provided, only properly signed cookie keys are returned.

set(
name: string,
value: string | null,
options?: CookiesSetDeleteOptions,
): Promise<this>

Set a cookie in the response headers.

If there was a keyring set, cookies will be automatically signed, unless overridden by the passed options. Cookies can be deleted by setting the value to null.

values(): AsyncIterableIterator<string>

Iterate over the request's cookies, yielding up the value of each cookie.

If a keyring was provided, only properly signed cookie values are returned.

[Symbol.asyncIterator](): AsyncIterableIterator<[string, string]>
[Symbol.for("nodejs.util.inspect.custom")](
depth: number,
options: any,
inspect: (value: unknown, options?: unknown) => string,
)