title: Cakephp 3.0 Login returns false every time
body: <p>I am trying to log in a user on my Cakephp 3.0 site. My table has a 'username' and 'password' field, named as is. I can add a user and my password is successfully getting hashed and stored in my table. Despite this, I am unable to log in even once.</p>
  
  <p>My AppController initialize() method:</p>
  
  <pre><code>$this-&gt;loadComponent('Auth',['loginAction' =&gt; [
                              'controller' =&gt; 'ShopOwners',
                              'action' =&gt; 'login'
                           ],'authenticate' =&gt; [
                                'Form' =&gt; [
                                  'fields' =&gt; [
                                    'username' =&gt; 'username',
                                    'password' =&gt; 'password',
                                   ],
                                   'userModel' =&gt; 'ShopOwners'
                                 ]
                           ],'loginRedirect' =&gt; [
                               'controller' =&gt; 'ShopOwners',
                               'action' =&gt; 'view'
                           ],
                      ]);
  $this-&gt;Auth-&gt;allow(['home','add']);
  </code></pre>
  
  <p>My login view function in my Controller</p>
  
  <pre><code>public function login(){
      $this-&gt;log('Inside login','debug');
      if($this-&gt;request-&gt;is('post')){
         $this-&gt;log('Inside login is post','debug');
         $shopOwner = $this-&gt;Auth-&gt;identify();
         if($shopOwner){
            $this-&gt;log('Inside is owner','debug');
            $this-&gt;Auth-&gt;setUser($shopOwner);
            return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl());
         }
        $this-&gt;Flash-&gt;error(__('Invalid username or password, try again'));
      }
  }
  </code></pre>
  
  <p>And finally my login view file login.ctp</p>
  
  <pre><code>&lt;h1&gt;Login&lt;/h1&gt;
  &lt;?= $this-&gt;Form-&gt;create(); ?&gt;
  &lt;?= $this-&gt;Form-&gt;input('username'); ?&gt;
  &lt;?= $this-&gt;Form-&gt;input('password'); ?&gt;
  &lt;?= $this-&gt;Form-&gt;button(__('Login')); ?&gt;
  &lt;?= $this-&gt;Form-&gt;end(); ?&gt;
  </code></pre>
  
  <p>I have tried many solutions offered on the site and elsewhere to try and fix this. These include:</p>
  
  <ol>
  <li>protected $_accessible is set corrrectly</li>
  <li>Checked that table column names are username and password exactly </li>
  <li>SQL query is returning 1 row, as checked through the Console, but Auth->identify() is not returning anything. </li>
  <li>Made many new users in case I had entered the wrong password, no luck nothing cleared </li>
  <li>Checked my file/table/column names to make everything matches[at least I think it's all fine] </li>
  <li>Also checked if the user is already logged in by using
  $this->Auth->user('username') which returned nothing</li>
  </ol>
  
  <p>New to Cakephp, and have been stuck at this one for a whole day now. Really appreciate any help.</p>
  
  <p>EDIT: Can someone at least tell me why identify() is not returning anything. I did a trace in my login function in the controller and it returned    </p>
  
  <pre><code>App\Controller\ShopOwnersController::login() - 
   APP/Controller\ShopOwnersController.php, line 132
  Cake\Controller\Controller::invokeAction() - 
   CORE\src\Controller\Controller.php, line 405
  Cake\Routing\Dispatcher::_invoke() - 
   CORE\src\Routing\Dispatcher.php, line 114
  Cake\Routing\Dispatcher::dispatch() - 
    CORE\src\Routing\Dispatcher.php, line 87
  [main] - ROOT\webroot\index.php, line 37
  </code></pre>
  
  <p>Ends with a:</p>
  
  <pre><code>Undefined variable: _SESSION [CORE\src\Network\Session.php, line 436]
  </code></pre>
  
  <p>Why is it stopping at index.php? What could be wrong? In the index I checked</p>
  
  <pre><code>print_r(Request::createFromGlobals());
  </code></pre>
  
  <p>In which I can see my data array contain the username and password, but still nothing. The password is text and not hashed, is that the problem??</p>
  
  <p>EDIT 2: My Request Object contains the following</p>
  
  <pre><code>[params] =&gt; Array ( [plugin] =&gt; [controller] =&gt; [action] =&gt; [_ext] =&gt; [pass] =&gt; Array ( ) ) 
  [data] =&gt; Array ( [username] =&gt; user9 [password] =&gt; user9 ) 
  [query] =&gt; Array ( )
  </code></pre>
  
  <p>Why is my query Array empty? Is it supposed to be??</p>
  
  <p>EDIT 3 - I tried to send in a hashed version of my password and reset request->data['password'] to the hashed version. This did not work because</p>
  
  <ol>
  <li>Hashed versions for the same word were different each time. I used (new DefaultPasswordHasher)->hash() for this</li>
  <li>I tried to copy paste the hashed version of the password from the database directly into my login form. No luck</li>
  </ol>