Reputation: 71
I tried to save an id
and a name
in a JSF Session but they are not being stored.
When I refresh the page it disappears. This is the code I'm using:
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.setAttribute("id", 123);
session.setAttribute("name", "a name");
what i want to do by session is securing my pages using a Filter and inside it im testing if the session existe or not
Please help me
Regards
Upvotes: 0
Views: 251
Reputation: 71
I solved my problem :D
I had a session scoped ManagedBean that was disappearing when the page was refreshed. So the problem is that the session was expiring after 1s or less. So I set the setSessionMaxInactiveInterval
to -1
which disables the session expiration timeout:
FacesContext.getCurrentInstance()
.getExternalContext()
.setSessionMaxInactiveInterval(-1);
Upvotes: 1