code: private CmsSessionInfo getSessionForUser(CmsUser user) {
  
          List<CmsSessionInfo> sessions = OpenCms.getSessionManager().getSessionInfos(user.getId());
  
          if (sessions.isEmpty()) {
              return null;
          }
  
          CmsSessionInfo currentSession = sessions.get(0);
          for (CmsSessionInfo session : sessions) {
              if (session.getTimeUpdated() > currentSession.getTimeUpdated()) {
                  currentSession = session;
              }
          }
          return currentSession;
      }
docs: Gets the most current session for given user.<p>
  
  @param user CmsUser to get session for
  @return CmsSessionInfo or null if no session is available for user