/** * {@inheritdoc} */ public function read($session_id) { $trace = \Drupal::service('session_test.session_handler_proxy_trace'); $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id]; $result = $this->sessionHandler->read($session_id); $trace[] = ['END', $this->optionalArgument, __FUNCTION__, $session_id]; return $result; }
/** * @param \Wandu\Http\Contracts\CookieJarInterface $cookieJar * @return \Wandu\Http\Contracts\SessionInterface */ public function fromCookieJar(CookieJarInterface $cookieJar) { $sessionName = $this->config['name']; if ($cookieJar->has($sessionName)) { $sessionId = $cookieJar->get($sessionName); } else { $sessionId = $this->generateId(); } $data = @unserialize($this->handler->read($sessionId)); return new Session($sessionId, $data ? $data : []); }
/** * @param ServerRequestInterface $request * @return Storage */ public function readFromRequest(ServerRequestInterface $request) { $cookies = $request->getCookieParams(); if (isset($cookies[$this->name])) { $this->id = $cookies[$this->name]; } else { $this->id = $this->generateId(); $this->reset = true; } return new Storage($this->handler->read($this->id)); }
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); } }
/** * Read the session data from the handler. * * @return array */ private function readFromHandler() : array { $data = $this->handler->read($this->id); if ($data) { return json_decode($this->encrypter->decrypt($data), true); } return []; }
/** * Read the session data from the handler. * * @return array */ protected function readFromHandler() { $data = $this->handler->read($this->getId()); if ($data) { $data = @unserialize($this->prepareForUnserialize($data)); if ($data !== false) { return $data; } } return []; }
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); } }
public function testGarbageCollection() { $countOfSessionFiles = $this->getCountOfSessionFiles(); $this->adapter->write('1', 'string 1'); $this->adapter->write('2', 'string 2'); $this->adapter->write('3', 'string 3'); // increase 3 files $this->assertEquals($this->getCountOfSessionFiles(), $countOfSessionFiles + 3); $this->assertTrue($this->adapter->gc(1)); $this->assertEquals('string 1', $this->adapter->read('1')); $this->assertEquals('string 2', $this->adapter->read('2')); $this->assertEquals('string 3', $this->adapter->read('3')); sleep(2); $this->assertTrue($this->adapter->gc(1)); // decrease 3 files $this->assertEquals($this->getCountOfSessionFiles(), $countOfSessionFiles); $this->assertEquals('', $this->adapter->read('1')); $this->assertEquals('', $this->adapter->read('2')); $this->assertEquals('', $this->adapter->read('3')); }
/** * Read the session data from the handler. * * @return array */ protected function readFromHandler() { $data = $this->handler->read($this->getId()); return $data ? unserialize($data) : array(); }
/** * {@inheritdoc} */ public function read($sessionId) { return (string) $this->handler->read($sessionId); }
/** * {@inheritdoc} */ public function read($sessionId) { $session = $this->wrappedSessionHandler->read($sessionId); $this->readSessions[$sessionId] = $session; return $session; }
/** * {@inheritdoc} */ public function read($session_id) { return $this->wrappedSessionHandler->read($session_id); }