Redirect to referrer not working after Login

后端 未结 1 1572
不知归路
不知归路 2021-01-26 02:57

After logging a user in, I want to redirect them back to where they came from but It\'s not working properly in CakePHP 3.5. Here are the required info\'s to help me figure out

相关标签:
1条回答
  • 2021-01-26 03:52

    I figured out my mistake, Actually, I was using for action URL like,

    $this->Form->create(NULL, ['url'=> ['controller' => 'Admins', 'action' => 'login'],'style'=>'display: block;');
    

    Because of this, the URL became "admins/login" and the redirect query string get removed that's why the problem occurred, because "$this->redirect($this->Auth->redirectUrl());" didn't find any redirect query string(as per the case 1), so it uses $this->Auth->config('loginRedirect');(as per case 2).

    Then I solve it by removing the URL key and value from the form create option parameter.

    0 讨论(0)
提交回复
热议问题