code: protected static Map<String, Object> getSessionAttributes(){
          //TODO: cache session attributes map since this method can be called multiple times during a request.
  
          HttpSession session = RequestContext.getHttpRequest().getSession(true);
          Enumeration names = session.getAttributeNames();
          Map<String, Object> values = new HashMap<>();
          while (names.hasMoreElements()) {
              Object name = names.nextElement();
              values.put(name.toString(), session.getAttribute(name.toString()));
          }
          return values;
      }
docs: Returns all session attributes in a map.
  
  @return all session attributes in a map.