Datastore/src/DatastoreSessionHandler.php
public function write($id, $data)
    {
        try {
            $key = $this->datastore->key(
                $this->kind,
                $id,
                ['namespaceId' => $this->namespaceId]
            );
            $entity = $this->datastore->entity(
                $key,
                [
                    'data' => $data,
                    't' => time()
                ],
                $this->options['entityOptions']
            );
            $this->transaction->upsert($entity);
            $this->transaction->commit();
        } catch (Exception $e) {
            trigger_error(
                sprintf('Datastore upsert failed: %s', $e->getMessage()),
                E_USER_WARNING
            );
            return false;
        }
        return true;
    }
public function write($id, $data)
    {
        try {
            $key = $this->datastore->key(
                $this->kind,
                $id,
                ['namespaceId' => $this->namespaceId]
            );
            $entity = $this->datastore->entity(
                $key,
                [
                    'data' => $data,
                    't' => time()
                ],
                $this->options['entityOptions']
            );
            $this->transaction->upsert($entity);
            $this->transaction->commit();
        } catch (Exception $e) {
            trigger_error(
                sprintf('Datastore upsert failed: %s', $e->getMessage()),
                E_USER_WARNING
            );
            return false;
        }
        return true;
    }
public function write ( $ id , $ data ) { try { $ key = $ this -> datastore -> key ( $ this -> kind , $ id , [ 'namespaceId' => $ this -> namespaceId ] ) ; $ entity = $ this -> datastore -> entity ( $ key , [ 'data' => $ data , 't' => time ( ) ] , $ this -> options [ 'entityOptions' ] ) ; $ this -> transaction -> upsert ( $ entity ) ; $ this -> transaction -> commit ( ) ; } catch ( Exception $ e ) { trigger_error ( sprintf ( 'Datastore upsert failed: %s' , $ e -> getMessage ( ) ) , E_USER_WARNING ) ; return false ; } return true ; }
Write the session data to Cloud Datastore.

@param string $id Identifier used to construct a {@see \Google\Cloud\Datastore\Key}
for the {@see \Google\Cloud\Datastore\Entity} to be written.
@param string $data The session data to write to the {@see \Google\Cloud\Datastore\Entity}.
@return bool
Write the session data to Cloud Datastore .