# Save Cookie - write (AJAX)

**URL:** <https://discourse.cakephp.org/t/save-cookie-write-ajax/2955>\
**Category:** Need Help\
**Tags:** release, i18n\
**Created:** [July 31, 2017, 12:09pm UTC](https://discourse.cakephp.org/t/save-cookie-write-ajax/2955 "2017-07-31T12:09:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabinhokls](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/fabinhokls/32/733_2.png) [@fabinhokls](https://discourse.cakephp.org/u/fabinhokls)\
**Post date:** [July 31, 2017, 12:09pm UTC](https://discourse.cakephp.org/t/save-cookie-write-ajax/2955/1 "2017-07-31T12:09:36Z")

</div>

I’m trying to save cookies with and I’m not getting it, it even returns with the $ this-\>read() function, but it does not save the cookie in the browser. No error is shown, just does not work. I am sending the data by ajax to a controller and it is calling the current component.

```
    namespace Cake\Controller\Component;
use Cake\Controller\Component;
use Cake\Controller\Component\CookieComponent;

class StepsComponent extends CookieComponent {
    public function criarStep($dataCookie, $StepCurrent) {
        $this->configKey($StepCurrent, [
            'path' => '/',
            'expires' => '+10 days',
            'httpOnly' => false,
            'encryption' => false
        ]);
        $this->write($StepCurrent, [$dataCookie]);
        return $this->read($StepCurrent);
    }
}
```
