title: Login page not going to next page; cakephp 3.4
body: <p>I have tried everything and my login page always stays on the LOGIN PAGE....</p>
  
  <p>this is my 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',//added this line
          'authenticate' =&gt; [
              'Form' =&gt; [
                  'fields' =&gt; [
                      'username' =&gt; 'username',
                      'password' =&gt; 'password'
                  ]
              ],
              //'scope'=&gt;['Users.activo' =&gt; 1]
          ],
          'loginAction' =&gt; [
              'controller' =&gt; 'Users',
              'action' =&gt; 'login'
          ],
          'loginAction' =&gt; [
              'controller' =&gt; 'Users',
              'action' =&gt; 'login'
          ],
          'unauthorizedRedirect' =&gt; $this-&gt;referer() // If unauthorized, return them to page they were just on
     ,  'loginRedirect' =&gt; [
          'controller' =&gt; 'Users',
          'action' =&gt; 'index'     
      ]
                 ]);
  
  
      $this-&gt;Auth-&gt;allow(['display','index','add']);
      //$this-&gt;Auth-&gt;allow('login', 'logout');
  
      $this-&gt;LoadModel('Huespedesxhabitaciones');
      $arr = $this-&gt;Huespedesxhabitaciones-&gt;ExQuery('SELECT checkin, checkout, concat(huespedes.nombre, " ", huespedes.apellidos) as huesped, habitaciones.nombre as habitacion fROM huespedesxhabitaciones INNER JOIN huespedes ON huespede_id = huespedes.id INNER JOIN habitaciones ON huespedesxhabitaciones.habitacione_id = habitaciones.id WHERE estado_id = 1');
      $this-&gt;set('ocupado', $arr);
  
      $this-&gt;LoadModel('Reservas');
      $arrs = $this-&gt;Reservas-&gt;ExQuery('SELECT reservas.id, reservas.habitacione_id, reservas.desde, reservas.hasta, reservas.precio, reservas.cliente as cliente, reservas.correo, habitaciones.nombre as habitacion FROM reservas INNER JOIN habitaciones ON reservas.habitacione_id = habitaciones.id'); 
      $this-&gt;set('reservado', $arrs);
  
  }`
  </code></pre>
  
  <p>and this is my userscontroller.php</p>
  
  <pre><code>public function index()
  {
      $users = $this-&gt;paginate($this-&gt;Users);
  
      $this-&gt;set(compact('users'));
      $this-&gt;set('_serialize', ['users']);
  }
  
  /**
   * View method
   *
   * @param string|null $id User id.
   * @return \Cake\Network\Response|null
   * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
   */
  public function view($id = null)
  {
      $user = $this-&gt;Users-&gt;get($id, [
          'contain' =&gt; []
      ]);
  
      $this-&gt;set('user', $user);
      $this-&gt;set('_serialize', ['user']);
  }
  
  /**
   * Add method
   *
   * @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise.
   */
  public function add()
  {
      $user = $this-&gt;Users-&gt;newEntity();
      if ($this-&gt;request-&gt;is('post')) {
          $user = $this-&gt;Users-&gt;patchEntity($user, $this-&gt;request-&gt;getData());
          if ($this-&gt;Users-&gt;save($user)) {
              $this-&gt;Flash-&gt;success(__('The user has been saved.'));
  
              return $this-&gt;redirect(['action' =&gt; 'index']);
          }
          $this-&gt;Flash-&gt;error(__('The user could not be saved. Please, try again.'));
      }
      $this-&gt;set(compact('user'));
      $this-&gt;set('_serialize', ['user']);
  }
  
  /**
   * Edit method
   *
   * @param string|null $id User id.
   * @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise.
   * @throws \Cake\Network\Exception\NotFoundException When record not found.
   */
  public function edit($id = null)
  {
      $user = $this-&gt;Users-&gt;get($id, [
          'contain' =&gt; []
      ]);
      if ($this-&gt;request-&gt;is(['patch', 'post', 'put'])) {
          $user = $this-&gt;Users-&gt;patchEntity($user, $this-&gt;request-&gt;getData());
          if ($this-&gt;Users-&gt;save($user)) {
              $this-&gt;Flash-&gt;success(__('The user has been saved.'));
  
              return $this-&gt;redirect(['action' =&gt; 'index']);
          }
          $this-&gt;Flash-&gt;error(__('The user could not be saved. Please, try again.'));
      }
      $this-&gt;set(compact('user'));
      $this-&gt;set('_serialize', ['user']);
  }
  
  /**
   * Delete method
   *
   * @param string|null $id User id.
   * @return \Cake\Network\Response|null Redirects to index.
   * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
   */
  public function delete($id = null)
  {
      $this-&gt;request-&gt;allowMethod(['post', 'delete']);
      $user = $this-&gt;Users-&gt;get($id);
      if ($this-&gt;Users-&gt;delete($user)) {
          $this-&gt;Flash-&gt;success(__('The user has been deleted.'));
      } else {
          $this-&gt;Flash-&gt;error(__('The user could not be deleted. Please, try again.'));
      }
  
      return $this-&gt;redirect(['action' =&gt; 'index']);
  }
  
  public function isAuthorized($user){
      //return $this-&gt;request-&gt;session()-&gt;read('Auth.User.role_id')=="6";
      return true;
  }
  public function login(){
   $this-&gt;log($this-&gt;request-&gt;data, LOG_DEBUG);
   $this-&gt;viewBuilder()-&gt;setLayout('login');
  if ($this-&gt;request-&gt;is('post')) {
      $user = $this-&gt;Auth-&gt;identify();
      if ($user) 
      {
          $this-&gt;Auth-&gt;setUser($user);
          return $this-&gt;redirect(['controller'=&gt;'users', 'action' =&gt; 'index']);
      }
      $this-&gt;Flash-&gt;error('Nombre de usuario y/o contraseña incorrecta');}
  </code></pre>
  
  <p>and this is my login.ctp</p>
  
  <pre><code>&lt;?php $this-&gt;HTML-&gt;css('login') ?&gt;
  
      &lt;div class="container"&gt;
  
         &lt;div class="users form"&gt;
  &lt;?= $this-&gt;Flash-&gt;render('auth') ?&gt;
  &lt;?= $this-&gt;Form-&gt;create() ?&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;&lt;?= __('Please enter your username and password') ?&gt;&lt;/legend&gt;
          &lt;?= $this-&gt;Form-&gt;input('username') ?&gt;
          &lt;?= $this-&gt;Form-&gt;input('password') ?&gt;
      &lt;/fieldset&gt;
  &lt;?= $this-&gt;Form-&gt;button(__('Login')); ?&gt;
  &lt;?= $this-&gt;Form-&gt;end() ?&gt;
  &lt;/div&gt;
      &lt;/div&gt;&lt;!-- /container --&gt;
  </code></pre>