title: How to override InvalidSessionStrategy in Spring Security
body: <p>The default implementation of InvalidSessionStrategy i.e. SimpleRedirectInvalidSessionStrategy in Spring security redirects the request to a default url. This default url comes from a final variable.</p>
  
  <p>I would like to override the behavior by not redirecting all the time to the same url. How could I achieve that ? If I create a custom implementation of InvalidSessionStrategy, how can I use that ?</p>
  
  <p>This is my configuration right now </p>
  
  <pre><code>and()
     .addFilterAfter(mySpringSecurityConfig.forceLogoutFilter(), PreAuthenticationFilter.class)
     .sessionManagement()
     .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
     .invalidSessionUrl("http://xxx/login.jsp")
     .sessionAuthenticationErrorUrl(PropertyMgr.getCarnivalURL("http://xxx/login.jsp"))
  </code></pre>
  
  <p>But I don't want to use "<a href="http://xxx/login.jsp" rel="nofollow">http://xxx/login.jsp</a>" for all invalid sessions. Thanks for the help.</p>