public function restoreLoginFromCookie()
    {
        if (! $this->cookieIsSet()) {
            return false;
        }

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

        foreach ($fields as $field) {
            if ($this->Cookie->check("$cookieKey.$field")) {
                $loginData[$field] = $this->Cookie->read("$cookieKey.$field");
            }
        }

        // $controller->request->data might need to be copied over to $this->request->data, depending on how Auth is looking for it
        $controller = $this->_registry->getController();
        $tempRequest = $controller->request->data;
        $controller->request->data = $loginData;
        $user = $controller->Auth->identify();
        $controller->request->data = $tempRequest;

        if ($user) {
            $controller->Auth->setUser($user);
            return true;
        }

        return false;
    }