I want to access to profile of the current user across the application (read/write). The user profile is an in instance of User 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)
        function loginAction()
            {
                $this->view->disable();
                {
                    $request = (array)$this->request->getJsonRawBody();
                    $user = User::findFirstByUsername($request['username']);
                    if (password_verify($request['password'], $user->password)) {
                        $userModel = User::findFirst('username="'.$request['username'].'"');
                        $this->getDI()['session']->set('auth', $user->id);
                        $this->user = $user;
                        jsonResponse($user->username);
                    } else {
                        http_response_code(401);
                        jsonResponse(['message' => 'invalid']);
                    }
                }
            }