0

How to use "remember me" cookie with auth in CakePHP 3? I have use the following code in my controller:

if ($this->request->data['data']['rememberMe'] == "on") {
    $cookie = array();
    $cookie['username'] = $this->request->data['username'];
    $cookie['password'] = $this->request->data['password']; 
    $this->request->Cookie->write('rememberMe', $cookie, true, "1 week");
    unset($this->request->data['rememberMe']);
}

and get the error :

Call to a member function write() on a non-object

Oops D'oh
  • 941
  • 1
  • 15
  • 34
Rishu
  • 97
  • 1
  • 2
  • 13

1 Answers1

1

Just like the error says. You should write cookies like this instead:

$this->Cookie->write ();

See this link for more detailed information: http://book.cakephp.org/3.0/en/controllers/components/cookie.html#Cake\Controller\Component\CookieComponent::write

makallio85
  • 1,366
  • 2
  • 14
  • 29