code: protected function updateFlashCounters()
      {
          $counters = $this->get($this->flashParam, []);
          if (is_array($counters)) {
              foreach ($counters as $key => $count) {
                  if ($count > 0) {
                      unset($counters[$key], $_SESSION[$key]);
                  } elseif ($count == 0) {
                      $counters[$key]++;
                  }
              }
              $_SESSION[$this->flashParam] = $counters;
          } else {
              // fix the unexpected problem that flashParam doesn't return an array
              unset($_SESSION[$this->flashParam]);
          }
      }
docs: Updates the counters for flash messages and removes outdated flash messages.
  This method should only be called once in [[init()]].