How can I set/get cookies?

Hi there, I’m new in Slim Framework.
Tell me please, how can I set some cookies by Slim native method? Does anything like that exist at least?

First of all, I tried to set cookies by $app->setCookies();, described in the docs, but I got BadMethodCallException: Method setCookie is not a valid method.

How can I solve that trouble?

Hi @medbrat13

$app->setCookies(); is a Slim 2 method. Cookies has been removed from the core.

In Slim 3 you can use the native PHP function setcookie function or any other Session/Cookie library/middleware.

Examples:

Oh, thanks, looks like I was reading the Slim 2 documentation all the time :slightly_smiling_face: