Exemple #1
0
 protected function initializeSession()
 {
     $this->data = [];
     $this->dataHash = null;
     $this->handler->open(null, $this->name);
     if (empty($this->id)) {
         $this->id = $this->generator->generateId();
     }
     $this->collectGarbage();
     // Must be done before read
     $data = $this->handler->read($this->id);
     if (!$data) {
         // Intentionally catch falsely values
         return;
     }
     if ($this->options->getBoolean('lazy_write', false)) {
         $this->dataHash = md5($data);
     }
     try {
         $this->data = $this->serializer->unserialize($data);
     } catch (\Exception $e) {
         // Destroy data upon unserialization error
         $this->handler->destroy($this->id);
     }
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function regenerate($destroy = false, $lifetime = null)
 {
     if (!$this->started) {
         $this->start();
     }
     if ($lifetime !== null) {
         $this->options['cookie_lifetime'] = $lifetime;
     }
     if ($destroy) {
         $this->metadataBag->stampNew($lifetime);
         $this->handler->destroy($this->id);
     }
     $this->id = $this->generator->generateId();
     return true;
 }