$usernameToken = unserialize($request->getSession()->get('_security_main')); $user = $usernameToken->getUser();