Пример #1
0
 /**
  * Read session data
  *
  * @param string $id
  * @return string
  */
 public function read($id)
 {
     $session = $this->mongoCollection->findOne(['_id' => $id, $this->options->getNameField() => $this->sessionName]);
     if (null !== $session) {
         // check if session has expired if index is not used
         if (!$this->options->useExpireAfterSecondsIndex()) {
             $timestamp = $session[$this->options->getLifetimeField()];
             $timestamp += floor((string) $session[$this->options->getModifiedField()] / 1000);
             // session expired
             if ($timestamp <= time()) {
                 $this->destroy($id);
                 return '';
             }
         }
         return $session[$this->options->getDataField()]->getData();
     }
     return '';
 }