Class: CookieCollection
Class: CookieCollection
Class representing a collection of Cookies.
Constructors
Constructor
protected new CookieCollection(
cookie?,
options?,
domDocument?): CookieCollection;
Create a CookieCollection.
Parameters
cookie?
string
String cookie from header.
options?
CookieOptions
= {}
Cookies options.
domDocument?
Document
Returns
CookieCollection
Methods
add()
add(
name,
value,
options): this;
Add a cookie to the collection.
Parameters
name
string
Cookie name.
value
unknown
Cookie value.
options
CookieOptions
= {}
Cookie options.
Returns
this
all()
all(): Cookie[];
Get all cookies in the collection.
Returns
Cookie
[]
clear()
clear(): this;
Clear all cookies from the collection.
Returns
this
get()
Get a cookie from the collection.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
Call Signature
get(name): undefined | Cookie;
Get a cookie from the collection.
Parameters
name
string
Cookie name.
Returns
undefined
| Cookie
Cookie value.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
Call Signature
get(name, fallback): Cookie;
Get a cookie from the collection.
Parameters
name
string
Cookie name.
fallback
Fallback value if the cookie does not exist.
Returns
Cookie value.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
getValue()
Get a cookie value from the collection.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
Call Signature
getValue<ValueType>(name): undefined | ValueType;
Get a cookie value from the collection.
Type Parameters
ValueType
ValueType
= unknown
Parameters
name
string
Cookie name.
Returns
undefined
| ValueType
Cookie value.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
Call Signature
getValue<ValueType>(name, fallback): ValueType;
Get a cookie value from the collection.
Type Parameters
ValueType
ValueType
= unknown
Parameters
name
string
Cookie name.
fallback
ValueType
Fallback value if the cookie does not exist.
Returns
ValueType
Cookie value.
Param
Cookie name.
Param
Fallback value if the cookie does not exist.
has()
has(name): boolean;
Check if the collection has a cookie.
Parameters
name
string
Cookie name.
Returns
boolean
isEmpty()
isEmpty(): boolean;
Check if the collection is empty.
Returns
boolean
remove()
remove(name, options): this;
Remove a cookie from the collection.
Parameters
name
string
Cookie name to remove.
options
CookieOptions
= {}
Cookie options.
Returns
this
secure()
secure(value): this;
Set secure flag for all cookies in the collection.
Parameters
value
boolean
= false
Whether the cookies are secure.
Returns
this
setOptions()
setOptions(options): this;
Set options for all cookies in the collection.
Parameters
options
Cookie options.
Returns
this
update()
update(
name,
value,
options): this;
Update a cookie in the collection.
Parameters
name
string
Cookie name.
value
unknown
New cookie value.
options
CookieOptions
= {}
Cookie options.
Returns
this
create()
static create(
cookie?,
options?,
domDocument?): CookieCollection;
Create a CookieCollection.
Parameters
cookie?
string
String cookie from header.
options?
CookieOptions
= {}
Cookies options.
domDocument?
Document
Returns
CookieCollection