title: Storing a model instance as a service during the session
body: <p>I want to access to profile of the current user across the application (read/write). The user profile is an in instance of <code>User</code> model. Is it possible to store it on session as a service? If not, what is best practice? 
  Here is my login code. (ajax-based login)</p>
  
  <pre><code>    function loginAction()
  {
      $this-&gt;view-&gt;disable();
      {
          $request = (array)$this-&gt;request-&gt;getJsonRawBody();
          $user = User::findFirstByUsername($request['username']);
  
          if (password_verify($request['password'], $user-&gt;password)) {
              $userModel = User::findFirst('username="'.$request['username'].'"');
              $this-&gt;getDI()['session']-&gt;set('auth', $user-&gt;id);
              $this-&gt;user = $user;
              jsonResponse($user);
          } else {
              http_response_code(401);
              jsonResponse(['message' =&gt; 'invalid']);
          }
      }
  }
  </code></pre>