How to stay logged in permanently using apache shiro

妖精的绣舞 提交于 2019-12-24 09:49:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!