write() public method

public write ( $session_id, $session_data )
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function write($sessionId, $sessionData)
 {
     if (isset($this->readSessions[$sessionId]) && $sessionData === $this->readSessions[$sessionId]) {
         return true;
     }
     return $this->wrappedSessionHandler->write($sessionId, $sessionData);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function write($session_id, $session_data)
 {
     $trace = \Drupal::service('session_test.session_handler_proxy_trace');
     $trace[] = ['BEGIN', $this->optionalArgument, __FUNCTION__, $session_id];
     $result = $this->sessionHandler->write($session_id, $session_data);
     $trace[] = ['END', $this->optionalArgument, __FUNCTION__, $session_id];
     return $result;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function write($session_id, $session_data)
 {
     if ($this->isSessionWritable()) {
         return $this->wrappedSessionHandler->write($session_id, $session_data);
     } else {
         return TRUE;
     }
 }
コード例 #4
0
ファイル: Manager.php プロジェクト: serendip811/patio42
 /**
  * @param ResponseInterface $response
  * @param Storage $storage
  * @return ResponseInterface
  */
 public function writeToResponse(ResponseInterface $response, Storage $storage)
 {
     $this->handler->write($this->id, $storage->toArray());
     if ($this->reset) {
         return $response->withHeader('Set-Cookie', "{$this->name}={$this->id}");
     }
     return $response;
 }
コード例 #5
0
ファイル: SessionFactory.php プロジェクト: wandu/http
 /**
  * @param \Wandu\Http\Contracts\SessionInterface $session
  * @param \Wandu\Http\Contracts\CookieJarInterface $cookieJar
  * @return \Wandu\Http\Contracts\SessionInterface $session
  */
 public function toCookieJar(SessionInterface $session, CookieJarInterface $cookieJar)
 {
     $sessionName = $this->config['name'];
     // save to handler
     $this->handler->write($session->getId(), serialize($session->getRawParams()));
     // apply to cookie-jar
     $cookieJar->set($sessionName, $session->getId(), (new DateTime())->setTimestamp(time() + $this->config['timeout']));
     // garbage collection
     $pick = rand(1, max(1, $this->config['gc_frequency']));
     if ($pick === 1) {
         $this->handler->gc($this->config['timeout']);
     }
     return $session;
 }
コード例 #6
0
ファイル: Store.php プロジェクト: jamilalidrus/Jamil
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $this->addBagDataToSession();
     $this->ageFlashData();
     $this->handler->write($this->getId(), $this->prepareForStorage(serialize($this->attributes)));
     $this->started = false;
 }
コード例 #7
0
ファイル: SessionStorage.php プロジェクト: robbert-vdh/bolt
 protected function write()
 {
     $data = $this->serializer->serialize($this->data);
     if ($this->options->getBoolean('lazy_write', false) && $this->handler instanceof LazyWriteHandlerInterface && md5($data) === $this->dataHash) {
         $this->handler->updateTimestamp($this->id, $data);
     } else {
         $this->handler->write($this->id, $data);
     }
 }
コード例 #8
0
ファイル: HandlerTestCase.php プロジェクト: wandu/framework
 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'));
 }
コード例 #9
0
ファイル: SessionStorage.php プロジェクト: atiarda/bolt
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     if (!$this->started || $this->closed) {
         throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
     }
     $data = $this->serializer->serialize($this->data);
     $this->handler->write($this->id, $data);
     $this->handler->close();
     $this->closed = true;
     $this->started = false;
 }
コード例 #10
0
ファイル: SessionHandlerProxy.php プロジェクト: scrobot/Lumen
 /**
  * {@inheritdoc}
  */
 public function write($sessionId, $data)
 {
     return (bool) $this->handler->write($sessionId, $data);
 }
コード例 #11
0
ファイル: Store.php プロジェクト: narrowspark/framework
 /**
  * Write values to handler.
  */
 private function writeToHandler()
 {
     $values = $this->values;
     $values[self::METADATA_NAMESPACE] = ['firstTrace' => $this->firstTrace, 'lastTrace' => $this->lastTrace, 'regenerationTrace' => $this->regenerationTrace, 'requestsCount' => $this->requestsCount, 'fingerprint' => $this->fingerprint];
     $this->handler->write($this->id, $this->encrypter->encrypt(json_encode($values, \JSON_PRESERVE_ZERO_FRACTION)));
 }