In other languages when a user logs in you can set the expire date of a cookie really far from today's and you can achieve this. How can I implement this in JSF2? I have a jsf sessionscoped bean but how can I maintain this session for a long time?.
Asked
Active
Viewed 1,513 times
2 Answers
4
You can add cookies with JSF as well:
FacesContext.getCurrentInstance().getExternalContext.addResponseCookie(..)
in the parameters map you can set the expiration date - see the documentation for all parameteres

Bozho
- 588,226
- 146
- 1,060
- 1,140
-
Yes but what I need to do is set the SessionScoped bean to last for a long time, not expire when the user closes his browser – arg20 Feb 13 '11 at 03:48
-
1@arg: This is not the right approach. When the session bean get created, it should just check the presence of the long-living cookie you've created before and then preinitialize the data associated with it. – BalusC Feb 13 '11 at 04:42
-
@BalusC I know it's a outdated comment but how would you do the login with the info you have in the cookie ? I'm actually looking at jaspic at the moment to do so. – Ced Jun 30 '15 at 01:13
0
I know this is tagged JSF but I recommend you look into Spring's Solution to the Remember Me problem.

Andrew White
- 52,720
- 19
- 113
- 137