Class: Cookie
Class: Cookie
Class representing a Cookie.
Constructors
Constructor
protected new Cookie(
name,
value,
options): Cookie;
Parameters
name
string
Cookie name.
value
unknown
Cookie value.
options
CookieOptions
= {}
Cookie options.
Returns
Cookie
Properties
name
readonly name: string;
options
readonly options: CookieOptions;
value
readonly value: unknown;
Methods
cloneWith()
cloneWith(value, options): Cookie;
Clone the cookie with new name, value, and options.
Parameters
value
unknown
New cookie value.
options
CookieOptions
= {}
New cookie options.
Returns
Cookie
A new cookie instance.
getValue()
getValue<ValueType>(): ValueType;
Get the cookie value.
Type Parameters
ValueType
ValueType
= unknown
Returns
ValueType
The cookie value.
serialize()
serialize(secret?): string;
Serialize the cookie value.
Parameters
secret?
string
Optional secret for signing.
Returns
string
setExpires()
setExpires(value): this;
Set expiration date for the cookie.
Parameters
value
Date
Expiration date.
Returns
this
setSecure()
setSecure(value): this;
Set secure flag for the cookie.
Parameters
value
boolean
Whether the cookie is secure.
Returns
this
create()
static create(
name,
value,
options): Cookie;
Create a Cookie.
Parameters
name
string
Cookie name.
value
unknown
Cookie value.
options
CookieOptions
= {}
Cookie options.
Returns
Cookie