public function setCookie($data = [])
    {
        $controller = $this->_registry->getController();
        if (empty($data)) {
            $data = $controller->request->data;
        }
        if (empty($data)) {
            $data = $controller->Auth->user();
        }
        if (empty($data)) {
            return false;
        }

        $fields = $this->config('fields');
        $cookieKey = $this->config('cookieKey');

        foreach ($fields as $field) {
            if (isset($data[$field]) && ! empty($data[$field])) {
                $this->Cookie->write("$cookieKey.$field", $data[$field]);
            }
        }

        return true;
    }