You are here

public function MongoDbSessionHandler::write in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php \Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler::write()

File

vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php, line 133

Class

MongoDbSessionHandler
MongoDB session handler.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

public function write($sessionId, $data) {
  $expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime'));
  $fields = array(
    $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY),
    $this->options['time_field'] => new \MongoDate(),
    $this->options['expiry_field'] => $expiry,
  );
  $this
    ->getCollection()
    ->update(array(
    $this->options['id_field'] => $sessionId,
  ), array(
    '$set' => $fields,
  ), array(
    'upsert' => true,
    'multiple' => false,
  ));
  return true;
}