code: public static Map<String, Object> createSessionMap(HttpServletRequest request) {
          Map<String, Object> sessionMap = new HashMap<>();
          HttpSession session = request.getSession(false);
  
          if (session != null) {
              for (Enumeration attributeNameEnum = session.getAttributeNames(); attributeNameEnum.hasMoreElements(); ) {
                  String attributeName = (String)attributeNameEnum.nextElement();
                  sessionMap.put(attributeName, session.getAttribute(attributeName));
              }
          }
  
          return sessionMap;
      }
docs: Creates a map from the session attributes in the specified request.
  
  @param request the request