Test Cookies

Key Value Action
  • View example/lib/widgets/example/auth.j2.html
  • Controller example/lib/controllers/home_controller.dart
  • Authentication Controller example/lib/controllers/auth_controller.dart
  • Router example/lib/route/web_route.dart
        
Future<String> exampleAddCookie() async {
  var name = rq.get<String>('name', def: '');
  var value = rq.get<String>('value', def: '');
  var safe = rq.get<bool>('safe', def: false);
  var action = rq.get<String>('action', def: 'add');

  if (action == 'delete') {
    // Remove cookie
    rq.removeCookie(name);                  
  } else if (action == 'add' && name.isNotEmpty && value.isNotEmpty) {
    // Add cookie
    rq.addCookie(name, value, safe: safe);  
  }

  return exampleCookie();
}