I must ensure unique session for my application so if user login to my application by Chrome browser and then login by Firefox browser, my application must notice user that there is other opened session.
Now I set my bean as ApplicationScope managing in login method this information:
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getApplicationMap().put("userCode" + userCode, user.getUserCode());
so when user login with other browser, my application compares userCode with
context.getExternalContext().getApplicationMap().get(userCode)
If userCode exists then:
context.getExternalContext().getSessionMap().clear();
context.getExternalContext().invalidateSession();
but is not enough because first session is still valid. Is it possible destroy all session among browser?