public function writeSession($id, $data)
    {
        // exception must be caught in session write handler
        // https://secure.php.net/manual/en/function.session-set-save-handler.php#refsect1-function.session-set-save-handler-notes
        try {
            // ensure backwards compatability (fixed #9438)
            if ($this->writeCallback && !$this->fields) {
                $this->fields = $this->composeFields();
            }
            // ensure data consistency
            if (!isset($this->fields['data'])) {
                $this->fields['data'] = $data;
            } else {
                $_SESSION = $this->fields['data'];
            }
            // ensure 'id' and 'expire' are never affected by [[writeCallback]]
            $this->fields = array_merge($this->fields, [
                'id' => $id,
                'expire' => time() + $this->getTimeout(),
            ]);
            $this->fields = $this->typecastFields($this->fields);
            $this->db->createCommand()->upsert($this->sessionTable, $this->fields)->execute();
            $this->fields = [];
        } catch (\Exception $e) {
            Yii::$app->errorHandler->handleException($e);
            return false;
        }
        return true;
    }
public function writeSession($id, $data)
    {
        
        
        try {
            
            if ($this->writeCallback && !$this->fields) {
                $this->fields = $this->composeFields();
            }
            
            if (!isset($this->fields['data'])) {
                $this->fields['data'] = $data;
            } else {
                $_SESSION = $this->fields['data'];
            }
            
            $this->fields = array_merge($this->fields, [
                'id' => $id,
                'expire' => time() + $this->getTimeout(),
            ]);
            $this->fields = $this->typecastFields($this->fields);
            $this->db->createCommand()->upsert($this->sessionTable, $this->fields)->execute();
            $this->fields = [];
        } catch (\Exception $e) {
            Yii::$app->errorHandler->handleException($e);
            return false;
        }
        return true;
    }
public function writeSession ( $ id , $ data ) { // exception must be caught in session write handler // https://secure.php.net/manual/en/function.session-set-save-handler.php#refsect1-function.session-set-save-handler-notes try { // ensure backwards compatability (fixed #9438) if ( $ this -> writeCallback && ! $ this -> fields ) { $ this -> fields = $ this -> composeFields ( ) ; } // ensure data consistency if ( ! isset ( $ this -> fields [ 'data' ] ) ) { $ this -> fields [ 'data' ] = $ data ; } else { $ _SESSION = $ this -> fields [ 'data' ] ; } // ensure 'id' and 'expire' are never affected by [[writeCallback]] $ this -> fields = array_merge ( $ this -> fields , [ 'id' => $ id , 'expire' => time ( ) + $ this -> getTimeout ( ) , ] ) ; $ this -> fields = $ this -> typecastFields ( $ this -> fields ) ; $ this -> db -> createCommand ( ) -> upsert ( $ this -> sessionTable , $ this -> fields ) -> execute ( ) ; $ this -> fields = [ ] ; } catch ( \ Exception $ e ) { Yii :: $ app -> errorHandler -> handleException ( $ e ) ; return false ; } return true ; }
Session write handler.
@internal Do not call this method directly.
@param string $id session ID
@param string $data session data
@return bool whether session write is successful
Session write handler .