setCookies method

FutureOr setCookies(
  1. String key,
  2. dynamic value, [
  3. DateTime? expireOn,
  4. bool? isSecure = true,
  5. bool httpOnly = true,
  6. int maxage = 15,
])

Implementation

FutureOr setCookies(String key ,var value, [DateTime? expireOn, bool? isSecure=true, bool httpOnly=true, int maxage = 15]) async {
  final cookie = Cookie(key, value.toString());
  DateTime now = new DateTime.now();
  DateTime date = new DateTime(now.year, now.month, now.day, now.hour, now.minute+15);
  cookie.httpOnly = httpOnly;
  cookie.secure = isSecure!;
  cookie.maxAge = maxage;
  cookie.expires = expireOn == '' ? date : expireOn;
  res?.cookies.add(cookie);

}