try {
User userProfile = userService.login(loginName,
encryptedPassword, true);
UserSession userSession = new UserSession();
userSession.setUserId(userProfile.getUserId());
userSession.setFirstName(userProfile.getFirstName());
userSession.setRole(userProfile.getRole());
applicationStateManager.set(UserSession.class,
userSession);
} catch (InstanceNotFoundException e) {
CookiesManager.removeCookies(cookies);