[英]How to stay logged in permanently using apache shiro
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 当用户第一次使用apache shiro登录时,需要知道如何在我的Java EE应用程序中永久保持登录状态
Any Idea? 任何想法?
Shiro supports "Remember me" facility. Shiro支持“记住我”功能。 Just provide a checkbox with name rememberMe
in the login form: 只需在登录表单中提供一个名称为rememberMe
的复选框:
<input type="checkbox" name="rememberMe" value="true" />
If you want to use JSF <h:selectBooleanCheckbox>
as follows, 如果<h:selectBooleanCheckbox>
以下方式使用JSF <h:selectBooleanCheckbox>
,
<h:form id="login">
<h:selectBooleanCheckbox id="rememberMe" />
Then you need to alter the shiro.ini
to add the following entry under [main]
: 然后,您需要更改shiro.ini
以在[main]
下添加以下条目:
authc.rememberMeParam = login:rememberMe
where login:rememberMe
is the JSF-generated client ID of the checkbox, representing the actual HTTP request parameter name. 其中login:rememberMe
是JSF生成的复选框的客户机ID,代表实际的HTTP请求参数名称。
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. 如果要默认checked="checked"
它,请在HTML输入中使用checked="checked"
,或在JSF组件中提供boolean=true
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.