title: How to manage session timeout expired
body: <p>I have the following trouble. My spring application is configured in the following way: </p>
  
  <p>Application context security</p>
  
  <pre><code>&lt;http use-expressions="true" pattern="/ext/**" entry-point-ref="loginUrlAuthenticationEntryPoint"&gt;
  
      //Others configuration
  
      &lt;session-management invalid-session-url="/sessionExpired"&gt;
      &lt;/session-management&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>@RequestMapping(value="/sessionExpired", method = RequestMethod.GET)
  public String sessionExpired(ModelMap model, HttpSession session) {
      return "login";
  }
  </code></pre>
  
  <p>Now my problem is that in the method sessionExpired I should be able to differentiate some property of my user for example:</p>
  
  <pre><code>  @RequestMapping(value="/sessionExpired", method = RequestMethod.GET)
  public String sessionExpired(ModelMap model, HttpSession session) {
  
       //Test1
       Authentication auth = SecurityContextHolder.getContext().getAuthentication();
       MyUser u = (MyUser) authentication.getPrincipal();
  
       //Test2 
       MyUser u = session.getAttribute("user");
  
       if(u.isItalian())
          return "loginA"
      else 
          return "loginB"
  
      return "login";
  }
  </code></pre>
  
  <p>I think that sping security has already cleaned session,request and SecurityContextHolder. Then how can I solve this situation?</p>