title: Login redirecting in cakePHP 3.4
body: <p>I'm trying to redirect to current page after logged in, using cakephp 3.4 but I'm getting like this </p>
  
  <blockquote>
    <p>localhost page isn't working, locahost page redirecting you too many
    times. Try clearing your cookies</p>
  </blockquote>
  
  <p>for 2 sec after that it's redirecting to home page. Please help me out here.
  Here my code</p>
  
  <p>In appController.php</p>
  
  <pre><code>public function initialize()
  { 
      parent::initialize();
      $this-&gt;loadComponent('RequestHandler');
      $this-&gt;loadComponent('Flash');
      $this-&gt;loadComponent('Auth', [
          'authorize' =&gt; ['Controller'],
          'authenticate' =&gt; [
              'Form' =&gt; [
                  'fields' =&gt; [
                      'username' =&gt; 'email',
                      'password' =&gt; 'password'
                  ],
                  'scope' =&gt; ['userStatus' =&gt; '1']
              ]
          ],
          'loginAction' =&gt; [
              'controller' =&gt; 'Users',
              'action' =&gt; 'login'
          ],
          'unauthorizedRedirect' =&gt; $this-&gt;referer(),
          'logoutRedirect'       =&gt; [
                  'controller' =&gt; 'Users',
                  'action'     =&gt; 'login'
          ]
      ]);
  }
  </code></pre>
  
  <p>In loginController.php</p>
  
  <pre><code>function login{ 
   if ( $this-&gt;request-&gt;is( 'post' ) ) {
      if ( $this-&gt;Auth-&gt;login() ) 
      {
         $this-&gt;redirect($this-&gt;referer());
      } 
      else {
        $this-&gt;Flash-&gt;error(__('Your username or password is incorrect.'));
      }
    }
  }
  </code></pre>