public function commit($unlock = true)
    {
        if (empty($this->insertions) && empty($this->deletions)) {
            return null;
        }

        $this->lock();

        $data = '';

        rewind($this->handle);

        $data = trim(stream_get_contents($this->handle));

        if ($data !== '') {
            $data = unserialize($data);

            $this->data = $this->insertions + $data;

            $data = null;

            foreach ($this->deletions as $key => $value) {
                unset($this->data[$key]);
            }
        } else {
            $this->data = $this->insertions;
        }

        $this->insertions = array();
        $this->deletions = array();

        $this->write();

        if ($unlock) {
            flock($this->handle, LOCK_UN);
        }

        $this->iterator = new \ArrayIterator($this->data);
    }
public function commit($unlock = true)
    {
        if (empty($this->insertions) && empty($this->deletions)) {
            return null;
        }

        $this->lock();

        $data = '';

        rewind($this->handle);

        $data = trim(stream_get_contents($this->handle));

        if ($data !== '') {
            $data = unserialize($data);

            $this->data = $this->insertions + $data;

            $data = null;

            foreach ($this->deletions as $key => $value) {
                unset($this->data[$key]);
            }
        } else {
            $this->data = $this->insertions;
        }

        $this->insertions = array();
        $this->deletions = array();

        $this->write();

        if ($unlock) {
            flock($this->handle, LOCK_UN);
        }

        $this->iterator = new \ArrayIterator($this->data);
    }
public function commit ( $ unlock = true ) { if ( empty ( $ this -> insertions ) && empty ( $ this -> deletions ) ) { return null ; } $ this -> lock ( ) ; $ data = '' ; rewind ( $ this -> handle ) ; $ data = trim ( stream_get_contents ( $ this -> handle ) ) ; if ( $ data !== '' ) { $ data = unserialize ( $ data ) ; $ this -> data = $ this -> insertions + $ data ; $ data = null ; foreach ( $ this -> deletions as $ key => $ value ) { unset ( $ this -> data [ $ key ] ) ; } } else { $ this -> data = $ this -> insertions ; } $ this -> insertions = array ( ) ; $ this -> deletions = array ( ) ; $ this -> write ( ) ; if ( $ unlock ) { flock ( $ this -> handle , LOCK_UN ) ; } $ this -> iterator = new \ ArrayIterator ( $ this -> data ) ; }
Lock session file and save variables
@param bool $unlock
@return void
Lock session file and save variables