rememberMe()



@Override
protected void configure(HttpSecurity http) throws Exception {
    http
    .formLogin()
    .loginPage("/login")
    .and()
    .rememberMe()
    .tokenValiditySeconds(1814400)
    .key("myPrivateKey")
    ...
}

Using rememberMe you can make the user login will be remembered by the application for specific amount of time.
be default the rememberMe feature stores a token in cookie and that is valid for two weeks.
the token is generated using the username, password and the private key and that combination is encoded using the MD5 hash
algorithm.
here the token will be expired after 1814400 seconds (three weeks)

You also need to add the remember-me field in the login page
<input id="remember_me" name="remember-me" type="checkbox"/>