title: Display username after login in cakephp3
body: <p>I want to display username after login in cakephp3. I write follow code but part of show username doesn't work. user after login redirect to main page.</p>
  
  <pre><code>Hi &lt;?php print $this-&gt;request-&gt;session()-&gt;read('User',$user); ?&gt;
  </code></pre>
  
  <p>login in UserController:</p>
  
  <pre><code>public function login() {
      if ($this-&gt;request-&gt;session()-&gt;read('login_ok') == '1') {
          $this-&gt;redirect(['controller' =&gt; 'users', 'action' =&gt; 'main']);
      }
      if ($this-&gt;request-&gt;is('post')) {
          //$hasher = new DefaultPasswordHasher();
          $count = $this-&gt;Users-&gt;find()
                  -&gt;where(['username' =&gt; $this-&gt;request-&gt;data['username'],
                      //    'password' =&gt; $this-&gt;request-&gt;data['password']])
                      'password' =&gt; md5($this-&gt;request-&gt;data['password'])])
                  -&gt;count();
          if ($count &gt; 0) {
              $result = true;
              $this-&gt;request-&gt;session()-&gt;write('User', $user); //store username
              $this-&gt;request-&gt;session()-&gt;write('login_ok', '1');
              $this-&gt;redirect(['controller' =&gt; 'users', 'action' =&gt; 'main']);
  
          } else {
              $result = false;
          }
          $this-&gt;set('result', $result);
      }
  }   
  
  public function main() {
      if ($this-&gt;request-&gt;session()-&gt;read('login_ok') != '1') {
          $this-&gt;redirect(['controller' =&gt; 'users', 'action' =&gt; 'login']);
      }
  
      $query = $this-&gt;request-&gt;session()-&gt;write('User',$user);
      $this-&gt;set('user', $query);
  }
  </code></pre>
  
  <p>and this main.ctp codes:</p>
  
  <pre><code>Hi &lt;?php print $this-&gt;request-&gt;session()-&gt;read('User', $user); ?&gt;
  </code></pre>
  
  <p>Can you help in making this Code OR Suggest a new code ?</p>