public function write($sessionId, $sessionData) {
        // serialize and encode the session data.
        $serializedData = base64_encode(serialize($sessionData));

        try {
            // try to retrive the stored session entity and update it.
            $result = $this->_tableRestProxy->getEntity($this->_sessionContainer, $this->_sessionContainerPartition, $sessionId);
            $entity = $result->getEntity();

            // update data and expiry time
            $entity->setPropertyValue('data', $serializedData);
            $entity->setPropertyValue('expires', time());

            // update entity
            $this->_tableRestProxy->updateEntity($this->_sessionContainer, $entity);
        } catch (ServiceException $e) {
            // otherwise, create a new session entity to store the data.
            $entity = new Entity();

            // set partition key and use session id as the row key.
            $entity->setPartitionKey($this->_sessionContainerPartition);
            $entity->setRowKey($sessionId);
            // set data and expiry time
            $entity->addProperty('data', EdmType::STRING, $serializedData);
            $entity->addProperty('expires', EdmType::INT32, time());

            // insert the entity
            $this->_tableRestProxy->insertEntity($this->_sessionContainer, $entity);
        }
        return TRUE;
    }
public function write($sessionId, $sessionData) {
        // serialize and encode the session data.
        $serializedData = base64_encode(serialize($sessionData));

        try {
            // try to retrive the stored session entity and update it.
            $result = $this->_tableRestProxy->getEntity($this->_sessionContainer, $this->_sessionContainerPartition, $sessionId);
            $entity = $result->getEntity();

            // update data and expiry time
            $entity->setPropertyValue('data', $serializedData);
            $entity->setPropertyValue('expires', time());

            // update entity
            $this->_tableRestProxy->updateEntity($this->_sessionContainer, $entity);
        } catch (ServiceException $e) {
            // otherwise, create a new session entity to store the data.
            $entity = new Entity();

            // set partition key and use session id as the row key.
            $entity->setPartitionKey($this->_sessionContainerPartition);
            $entity->setRowKey($sessionId);
            // set data and expiry time
            $entity->addProperty('data', EdmType::STRING, $serializedData);
            $entity->addProperty('expires', EdmType::INT32, time());

            // insert the entity
            $this->_tableRestProxy->insertEntity($this->_sessionContainer, $entity);
        }
        return TRUE;
    }
public function write ( $ sessionId , $ sessionData ) { // serialize and encode the session data. $ serializedData = base64_encode ( serialize ( $ sessionData ) ) ; try { // try to retrive the stored session entity and update it. $ result = $ this -> _tableRestProxy -> getEntity ( $ this -> _sessionContainer , $ this -> _sessionContainerPartition , $ sessionId ) ; $ entity = $ result -> getEntity ( ) ; // update data and expiry time $ entity -> setPropertyValue ( 'data' , $ serializedData ) ; $ entity -> setPropertyValue ( 'expires' , time ( ) ) ; // update entity $ this -> _tableRestProxy -> updateEntity ( $ this -> _sessionContainer , $ entity ) ; } catch ( ServiceException $ e ) { // otherwise, create a new session entity to store the data. $ entity = new Entity ( ) ; // set partition key and use session id as the row key. $ entity -> setPartitionKey ( $ this -> _sessionContainerPartition ) ; $ entity -> setRowKey ( $ sessionId ) ; // set data and expiry time $ entity -> addProperty ( 'data' , EdmType :: STRING , $ serializedData ) ; $ entity -> addProperty ( 'expires' , EdmType :: INT32 , time ( ) ) ; // insert the entity $ this -> _tableRestProxy -> insertEntity ( $ this -> _sessionContainer , $ entity ) ; } return TRUE ; }
Callback function for session handler. It's invoked while the session data is being written.

@param $sessionId The session ID.
@param $sessionData The data to be written in session.

@return boolean If the write operation success.
Callback function for session handler . It s invoked while the session data is being written .