set static method

void set(
  1. String name,
  2. String value, {
  3. bool httpOnly = true,
  4. bool? secure,
  5. String path = '/',
  6. Duration? maxAge,
  7. DateTime? expires,
  8. String? sameSite,
})

Set a cookie

Implementation

static void set(
  String name,
  String value, {
  bool httpOnly = true,
  bool? secure,
  String path = '/',
  Duration? maxAge,
  DateTime? expires,
  String? sameSite,
}) {
  final appEnv = FlintEnv.get('APP_ENV', 'development').toLowerCase();
  final resolvedSecure = secure ??
      FlintEnv.getBool('SESSION_COOKIE_SECURE', appEnv == 'production');
  final resolvedSameSite =
      sameSite ?? FlintEnv.get('SESSION_COOKIE_SAMESITE', 'Lax');

  _response.setCookie(
    name,
    value,
    path: path,
    httpOnly: httpOnly,
    secure: resolvedSecure,
    maxAge: maxAge?.inSeconds,
    expires: expires,
    sameSite: resolvedSameSite,
  );
}