getCookies function
Parses the cookies sent by the client (the request Cookie header).
Implementation
Map<String, String> getCookies(Context c) {
final header = c.req.header('cookie');
if (header == null) return {};
final cookies = <String, String>{};
for (final part in header.split(';')) {
final trimmed = part.trim();
if (trimmed.isEmpty) continue;
// Split on the FIRST '=' only — cookie values may contain '=' (e.g. the
// base64url padding used by signed/session cookies).
final eq = trimmed.indexOf('=');
if (eq <= 0) continue;
final name = trimmed.substring(0, eq).trim();
cookies[name] = trimmed.substring(eq + 1).trim();
}
return cookies;
}