/**
  * Tags this session with the given tag.
  *
  * Note that third-party libraries might also tag your session. Therefore it is
  * recommended to use namespaced tags such as "Acme-Demo-MySpecialTag".
  *
  * @param string $tag The tag – must match be a valid cache frontend tag
  * @return void
  * @throws Exception\SessionNotStartedException
  * @throws \InvalidArgumentException
  * @api
  */
 public function addTag($tag)
 {
     if ($this->started !== true) {
         throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355143533);
     }
     if (!$this->metaDataCache->isValidTag($tag)) {
         throw new \InvalidArgumentException(sprintf('The tag used for tagging session %s contained invalid characters. Make sure it matches this regular expression: "%s"', $this->sessionIdentifier, FrontendInterface::PATTERN_TAG));
     }
     if (!in_array($tag, $this->tags)) {
         $this->tags[] = $tag;
     }
 }