getCookie method
Retrieves a cookie value from the request.
Optionally decrypts the cookie value if safe
is true.
key
- The name of the cookie.
def
- The default value to return if the cookie is not found. Default is an empty string.
safe
- A flag indicating whether to decrypt the cookie value. Default is true.
Returns a String containing the cookie value.
Implementation
String getCookie(
String key, {
String def = '',
bool safe = true,
}) {
for (var cookie in _rq.cookies) {
if (cookie.name == key) {
if (!safe) {
return cookie.value;
} else {
return cookie.value.fromSafe(WaServer.config.cookiePassword);
}
}
}
return def;
}