CakePHP 2.0 Automatic Login after Account Activation

荒凉一梦 提交于 2019-12-04 07:41:30

Found a solution after testing many variations.

Works now with:

$user = $this->User->findById($id);
$user = $user['User'];
$this->Auth->login($user);

Don't know why, i thought i tried this way already and that did not work.

vinzcelavi

Have you tried this? (CakePHP 2.x)

public function signup() {   
  if (!empty($this->request->data)) {
    // Registration stuff

    // Auto login
    if ($this->Auth->login()) {
      $this->redirect('/');
    }
  }
}

That simple!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!