Remember me in Spring Security


I love Spring when it is very easy to add new stuff to your current projects. Recently I was asked to add Remember me checkbox to login page. If you are using Spring Security what you just need to do is as follows:

add this to your spring xml : <remember-me key="Your_key_with_values_like*!casAA='0401./e;2009NrI"/>

and add a checkbox to your login page ( id is important here ) : <h:selectBooleanCheckbox id="_spring_security_remember_me" />

and that is. Spring will do all the work for you.

Just remember if you have an exception about transactions, just add a @Transactional to your method which loads the user from the DB.