title: Spring Session scope use for user login
body: <p>I'am new to spring and hibernate.I used a POJO class for maintain a sessoin data.i put scope as a session. here</p>
  
  <pre><code>@Component
  @Scope("session")
  public class SessionInfo {
      private int userId;
      private String loggingUser;
  
  // getter and setter methods
  
  }
  </code></pre>
  
  <p>then my controller class set as a scope="request" and methods in that controller i can pass the sessionInfo class and set/get session data.</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET)
      public String index(Model model,SessionInfo session) {
          session.setLoggingUser("akudahewa@gmail.com");
          // set model attributes ....
          return "BusinessCategory/index";
      } 
  </code></pre>
  
  <p>Thats how i maintaining a session data in my application. In this way every time i need to pass the sessionInfo class in every method where needed and check is there any user in the session object, Is is way correct or not. and also cant we use intercepter for this. If not what is the best way to maintain the session data in spring.</p>