问题
A need to know how to stay logged in permanently in my Java EE application when the user logged in at first time using apache shiro
Any Idea?
回答1:
Shiro supports "Remember me" facility. Just provide a checkbox with name rememberMe
in the login form:
<input type="checkbox" name="rememberMe" value="true" />
If you want to use JSF <h:selectBooleanCheckbox>
as follows,
<h:form id="login">
<h:selectBooleanCheckbox id="rememberMe" />
Then you need to alter the shiro.ini
to add the following entry under [main]
:
authc.rememberMeParam = login:rememberMe
where login:rememberMe
is the JSF-generated client ID of the checkbox, representing the actual HTTP request parameter name.
If you want to have it checked by default, use checked="checked"
in the HTML input, or provide a boolean=true
property in the JSF component.
See also:
- JSF2 - Shiro tutorial
来源:https://stackoverflow.com/questions/18917360/how-to-stay-logged-in-permanently-using-apache-shiro