public function testWriteSession() { $sessionId = sha1(uniqid()); // write $this->adapter->write($sessionId, serialize(['hello' => 'world', 'what' => 'um..'])); // then data $this->assertEquals(['hello' => 'world', 'what' => 'um..'], unserialize($this->adapter->read($sessionId))); // destroy $this->adapter->destroy($sessionId); // then blank $this->assertEquals('', $this->adapter->read($sessionId)); }
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); } }
/** * {@inheritdoc} */ public function migrate($destroy = false, $lifetime = null) { if ($destroy) { $this->handler->destroy($this->getId()); } $this->id = $this->generateSessionId(); return true; }
/** * {@inheritdoc} */ public function migrate(bool $destroy = false) : bool { if ($destroy) { $this->handler->destroy($this->id); } $this->id = $this->generateSessionId(); $this->regenerationTrace = $this->timestamp(); return true; }
protected function initializeSession() { $this->handler->open(null, $this->id); $data = $this->handler->read($this->id); try { $this->data = $this->serializer->unserialize($data); } catch (\Exception $e) { // Destroy data upon unserialization error $this->handler->destroy($this->id); } }
/** * {@inheritdoc} */ public function destroy($sessionId) { return (bool) $this->handler->destroy($sessionId); }
/** * {@inheritdoc} */ public function destroy($sessionId) { return $this->wrappedSessionHandler->destroy($sessionId); }
/** * {@inheritdoc} */ public function destroy($session_id) { return $this->sessionHandler->destroy($session_id); }