Cookie
import { Cookie } from "jsr:@ende/http";interface
interface CookieRepresents an HTTP Cookie.
See also
Properties
name
name: stringName of the cookie.
value
value: stringValue of the cookie.
expires
expires?: Date | numberThe cookie's Expires attribute, either as an explicit date or UTC
milliseconds. If undefined, the cookie will expire when the client's
session ends.
Example:
import { Cookie } from "@ende/http/cookie";
const cookie: Cookie = {
name: 'name',
value: 'value',
// expires on Fri Dec 30 2022
expires: new Date('2022-12-31')
}
Example:
import { Cookie } from "@ende/http/cookie";
const cookie: Cookie = {
name: 'name',
value: 'value',
// expires 10 seconds from now
expires: Date.now() + 10000
}
maxAge
maxAge?: numberThe cookie's Max-Age attribute, in seconds. Must be a non-negative
integer. A cookie with a maxAge of 0 expires immediately.
domain
domain?: stringThe cookie's Domain attribute. Specifies those hosts to which the cookie
will be sent.
path
path?: stringThe cookie's Path attribute. A cookie with a path will only be included
in the Cookie request header if the requested URL matches that path.
secure
secure?: booleanThe cookie's Secure attribute. If true, the cookie will only be
included in the Cookie request header if the connection uses SSL and
HTTPS.
Default: false
httpOnly
httpOnly?: booleanThe cookie's HTTPOnly attribute. If true, the cookie cannot be accessed via JavaScript.
Default: false
partitioned
partitioned?: booleanThe cookie's Partitioned attribute.
If true, the cookie will be only be included in the Cookie request header if
the domain it is embedded by matches the domain the cookie was originally set from.
Warning: This is an attribute that has not been fully standardized yet. It may change in the future without following the semver semantics of the package. Clients may ignore the attribute until they understand it.
Default: false
sameSite
sameSite?: "Strict" | "Lax" | "None"Allows servers to assert that a cookie ought not to be sent along with cross-site requests.
unparsed
unparsed?: string[]Additional key value pairs with the form "key=value".
Default: []