CookieParser class

Parses cookies from the Cookie header of a Request.

Stores all cookies in a cookies list, and has convenience methods to manipulate this list.

Constructors

CookieParser([String secretKey = ""])
CookieParser.fromCookieValue(String? value, [String secretKey = ""])
Creates a new CookieParser by parsing the Cookie header value.
CookieParser.fromHeader(Map<String, dynamic> headers, [String secretKey = ""])
Factory constructor to create a new instance from request headers.
factory

Properties

cookies List<Cookie>
final
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Denotes whether the cookies list is empty.
no setter
isResponseEmpty bool
no setter
responseCookies List<Cookie>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clears the cookie list.
get(String name) Cookie?
Retrieves a cookie by name.
getEncrypted(String name) Future<Cookie?>
Retrieves a deciphered cookie by name.
getResponse(String name) Cookie?
Retrieves a response cookie by name. You will rarely need this, but in case.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String name) → void
Removes a cookie from list by name. Note: this does not delete a cookie in the browser To remove the cookie from browser cache you need to set a new one with exactly same name, path and domain, but with the expires date in the past, value is irrelevant
set(String name, String value, {String? domain, String? path, DateTime? expires, bool? httpOnly, bool? secure, int? maxAge}) Cookie
Adds a new cookie to responseCookies list.
setEncrypted(String name, String value, {String? domain, String? path, DateTime? expires, bool? httpOnly, bool? secure, int? maxAge}) Future<Cookie>
Adds a new ciphered cookie to cookies list.
toHeader() List<String>
Use this method to set Response's 'set-cookie' header Shelf now supports multiple 'set-cookie' values, that is why method returns List
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited