Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/another_cookiejar/cookie_jar.ts>CookieJar

https://deno.land/x/another_cookiejar
Go to Latest
class CookieJar
import { CookieJar } from "https://deno.land/x/another_cookiejar@v5.0.2/cookie_jar.ts";

Constructors

new
CookieJar(cookies?: Array<Cookie> | Array<CookieOptions>)

Properties

cookies

Methods

getCookie(options: Cookie | CookieOptions): Cookie | undefined

Gets the first cooking matching the defined properties of a given Cookie or CookieOptions. returns undefined if not found or expired. creationDate prop is not checked. Also removes the cookie and returns undefined if cookie is expired.

Returns cookies that match the options excluding expired ones, also removes expired cookies before returning.

getCookieString(url: string | Request | URL)

Converts the cookies to a string that can be used in a request.

removeCookie(options: CookieOptions | Cookie): Cookie | undefined

Removes first cookie that matches the given option.

Returns the deleted cookie if found or undefined otherwise.

removeCookies(options?: CookieOptions | Cookie): Array<Cookie> | undefined

Removes all cookies that matches the given option. If options is not given, all cookies will be deleted.

Returns the deleted cookies if found or undefined otherwise.

replaceCookies(cookies?: Array<Cookie> | Array<CookieOptions>)
setCookie(cookie: Cookie | string, url?: string | Request | URL)

Sets or replaces a cookie inside the jar. Only sets new cookies if cookie is valid and not expired. Validation and expiration checks are not run when replacing a cookie.