Brief: How can i redirect to the login page when commandButton is pressed and the user is not logged in anymore?
In detail: I am trying to solve the following scenario in my primefaces application:
- I successfully log in in my web application
- I open a new tab while logged in.
- Now i log out from the second tab that i opened on step 2. In this tab i get redirected to the login page
- Press a commandButton from the 1st tab that still looks like if the user logged in but not many things happen .
When trying to access a page through a link while logged out, then yes i am redirected to the login page. The same does not happen though with the commandButton component.
I am using a filter already and tried to catch that case, meaning to confirm if on button press the session is null to redirect me to login page. As seen here: https://stackoverflow.com/a/1027592/1918516
The problem is that even though i logged out from the 2nd tab, and press a button from the 1st tab, my session is never null.
Update: After logging out and invalidate the session with invalidateSession() i see that my session is null. But when press on a button from the first tab, the session is NOT null. Could this be that the browsers cache is somehow maintaining an invalid session ?
Also i want to note here that i am retrieving the session with request.getSession(false)