cookie method

  1. @override
String? cookie(
  1. String key, {
  2. bool decrypt = true,
})
override

get cookie value from header. An encrypted cookie that was changed, made with another key, or made for another cookie name gives null.

req.cookie('authKey');

Implementation

@override
String? cookie(String key, {bool decrypt = true}) {
  if (_cookies[key] == null) return null;
  if (!decrypt) return _cookies[key];
  try {
    return AESEncryptor.decode(
      _cookies[key],
      Dox().config.appKey,
      associatedData: key,
    );
  } on DecryptException {
    return null;
  }
}