0

I'm trying to enable a "remember me" option in my cakePhp app. I used this CakePHP remember me with Auth answer to implement it. So looks my UsersController:

if ( (int)$this->request->data['User']['remember_me'] == 1 ) {
                // remove "remember me checkbox"
                unset($this->request->data['User']['remember_me']);     

                $this->request->data['User']['pw2'] = $this->request->data['User']['password'];

                // write the cookie
                $this->Cookie->write('remember_me_cookie', $this->request->data['User'], true, '2 weeks');
            }

This is the logic from Model:

$this->Cookie->httpOnly = true;

        if (!$this->Auth->loggedIn() && $this->Cookie->read('remember_me_cookie')) {
            $cookie = $this->Cookie->read('remember_me_cookie');
            $user = $this->User->find('first', array(
                    'conditions' => array(
                            'User.username' => $cookie['username'],
                            'User.password' => $cookie['password'],
                    )
            ));


    }

This is the view(i know it's not perfect)

echo $this->Form->checkbox('remember_me').'Remember me';

But remember me function doesn't work. What could be wrong ?

Community
  • 1
  • 1
handkock
  • 1,067
  • 2
  • 11
  • 23

0 Answers0