Setting a cookie in Slim Framework will require a key, value, and specific time to allow the cookie to be present.

BY Best Interview Question ON 30 Jan 2019

Example

// With all parameters

$app->setCookie(
   $name,
   $value,
   $expiresAt,
   $path,
   $domain,
   $secure,
   $httponly
);


// To set Cookie
$app->setCookie('bestinterviewquestion', 'bar', '2 days');

// To get Cookie
$app = new \Slim\Slim();
$foo = $app->getCookie('bestinterviewquestion');