title: CakePHP 3 refresh session data
body: <p>I have a page where i can modify user details (username,first name,avatar...).
  I have an element in my navbar with informations about the currently logged in user. The thing is I can't figure out how to refresh the session immediately after data is modified.</p>
  
  <p>in <strong>UsersController</strong>:</p>
  
  <pre><code>public function edit($id = null)
  {
      if (!$id) {
          throw new NotFoundException(__('Invalid user'));
      }
  
      $user = $this-&gt;Users-&gt;get($id);
      if ($this-&gt;request-&gt;is(['post', 'put'])) {
          $this-&gt;Users-&gt;patchEntity($user, $this-&gt;request-&gt;data);
          if ($this-&gt;Users-&gt;save($user)) {
  
              //REFRESH SESSION ????\\
              $this-&gt;request-&gt;session()-&gt;write('Auth.User', $user);
              //\\
  
              $this-&gt;Flash-&gt;success(__('User has been updated.'));
              return $this-&gt;redirect(['action' =&gt; 'edit/' . $id]);
          }
          $this-&gt;Flash-&gt;error(__('Unable to update User details.'));
      }
  
      $this-&gt;set(compact('user'));
  }
  </code></pre>