Cookies class
Cookies Manager
A clean and solid cookie management system that provides a unified interface for handling HTTP cookies in requests and responses.
Constructors
- Cookies(HttpRequest? _request)
- Creates a Cookies instance for a request (read-only).
- Cookies.context(HttpRequest? _request, HttpResponse? _response)
- Creates a Cookies instance for both request and response.
- Cookies.response(HttpResponse? _response)
- Creates a Cookies instance for a response (write-only).
Properties
-
all
→ Map<
String, String> -
Gets all cookies from the request as a map.
no setter
- csrfToken → String?
-
Gets the CSRF token cookie.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- rememberToken → String?
-
Gets the remember token cookie.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearRememberToken(
) → void - Clears the remember token cookie.
-
delete(
String name, {String? domain, String? path = '/'}) → void - Deletes a cookie by setting it to expire immediately.
-
deleteAll(
List< String> names, {String? domain, String? path = '/'}) → void - Deletes multiple cookies at once.
-
get(
String name) → String? - Gets a cookie value from the request.
-
getCookie(
String name) → Cookie? - Gets a cookie object from the request.
-
getFlashMessage(
) → Map< String, String> ? - Gets flash message from request and clears it (if response is available).
-
has(
String name) → bool - Checks if a cookie exists in the request.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
String name, String value, {String? domain, String? path = '/', DateTime? expires, Duration? maxAge, bool httpOnly = false, bool secure = false, String? sameSite}) → void - Sets a cookie in the response.
-
setAll(
Map< String, String> cookies, {String? domain, String? path = '/', DateTime? expires, Duration? maxAge, bool httpOnly = false, bool secure = false, String? sameSite}) → void - Sets multiple cookies at once.
-
setFlashMessage(
String type, String message, {bool secure = false}) → void - Sets a flash message cookie.
-
setRememberToken(
String token, {Duration maxAge = const Duration(days: 30), bool secure = false, bool httpOnly = true}) → void - Sets the remember token cookie.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited