Loading…

How to set and get a cookie in Slim Framework?

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

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');

Suggest An Answer

No suggestions avaliable!

Latest post from Slim Interview Questions

Ask Question