title: Get the current session with spring-session
body: <p>Here's my question: I'm writing a platform which I will be giving to the customers to implement their projects with. So in my platform I have created a <code>SessionService</code> in which I have methods like <code>getCurrentSession</code>, <code>getAttribute</code>, <code>setAttribute</code>, etc. Before spring-session my <code>getCurrentMethod</code> looked like this:</p>
  
  <p><code>
      @Override
      public HttpSession getCurrentSession() {
          if (this.session == null) {
              final ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
              return attr.getRequest().getSession(true); // true == allow create
          }
          return this.session;
      }
  </code></p>
  
  <p>which worked perfectly fine, although it looks ugly and have no backing like redis. Now I want to migrate to <code>spring-session</code> and I was hoping to use the <code>SessionRepository</code> to find the current session of the user, however I can only see a <code>getSession(String id)</code> in there. I believe the id is stored in the cookie, so to use it I will probably have to pass the <code>HttpServletRequest</code> object from my controllers, to my facades, to the service layer which is very near the db layer. This looks like a very bad idea to me, so my question would be: is there any way to get the currentSession near the db layer? One way I would think is to write an interceptor that will be invoked the controllers, which will set the current session in the repository, or the service maybe? I'm just not sure this is the right way to go.</p>