JSF“记住我”选项
问题描述:
在其他语言中,当用户登录时,您可以将Cookie的过期日期设置为远离今天,并且您可以实现此目的。我怎样才能在JSF2中实现它?我有一个jsf sessionscoped bean但是我怎么能长时间保持这个会话?。
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?.
答
你可以用JSF添加cookie以及:
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