# How can I set/get cookies?

**URL:** <https://discourse.slimframework.com/t/how-can-i-set-get-cookies/3155>\
**Category:** Questions\
**Created:** [May 9, 2019, 6:34pm UTC](https://discourse.slimframework.com/t/how-can-i-set-get-cookies/3155 "2019-05-09T18:34:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![medbrat13](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@medbrat13](https://discourse.slimframework.com/u/medbrat13)\
**Post date:** [May 9, 2019, 6:34pm UTC](https://discourse.slimframework.com/t/how-can-i-set-get-cookies/3155/1 "2019-05-09T18:34:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [May 9, 2019, 6:47pm UTC](https://discourse.slimframework.com/t/how-can-i-set-get-cookies/3155/2 "2019-05-09T18:47:53Z")

</div>

Hi @medbrat13

`$app->setCookies();` is a [Slim 2](https://docs.slimframework.com/response/cookies/) method. Cookies has been removed from the core.

In Slim 3 you can use the native PHP function [setcookie](https://www.php.net/manual/en/function.setcookie.php) function or any other Session/Cookie library/middleware.

Examples:

- [GitHub - dflydev/dflydev-fig-cookies: Cookies for PSR-7 HTTP Message Interface.](https://github.com/dflydev/dflydev-fig-cookies)
- [GitHub - laminas/laminas-session: Object-oriented interface to PHP sessions and storage](https://github.com/laminas/laminas-session/)
- [GitHub - odan/session: A session handler for PHP and Slim 4+](https://github.com/odan/session)

---

<div class="post-metadata">

**Author:** ![medbrat13](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@medbrat13](https://discourse.slimframework.com/u/medbrat13)\
**Post date:** [May 9, 2019, 6:59pm UTC](https://discourse.slimframework.com/t/how-can-i-set-get-cookies/3155/3 "2019-05-09T18:59:27Z")

</div>

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