/** Invalidate all sessions that have expired. */
  private void processExpires() {

    long timeNow = System.currentTimeMillis();
    Session sessions[] = findSessions();

    for (int i = 0; i < sessions.length; i++) {
      StandardSession session = (StandardSession) sessions[i];
      if (!session.isValid()) continue;
      int maxInactiveInterval = session.getMaxInactiveInterval();
      if (maxInactiveInterval < 0) continue;
      int timeIdle = // Truncate, do not round up
          (int) ((timeNow - session.getLastAccessedTime()) / 1000L);
      if (timeIdle >= maxInactiveInterval) {
        try {
          session.expire();
        } catch (Throwable t) {
          log(sm.getString("standardManager.expireException"), t);
        }
      }
    }
  }