src/Web/Sessions/SessionArchiveInFiles.php
public function set($id, $data)
    {
        $dataSr = $this->getHandler()->serializeData($data);
        /** @var File $file */
        $file = null;
        $createMode = FileHelperAsc::permissionsAsString(0777);
        $writePromise = $this->getArchiveFilePath($id)->then(
            function($filePath) use (&$file) {
                $file = \Reaction::$app->fs->file($filePath);
                return \Reaction::$app->fs->file($filePath)->exists();
            }
        )->then(null,
            function() use (&$file, $createMode) { return $file->create($createMode); }
        )->then(
            function() use (&$file) { return $file->open('w'); }
        )->then(
            function(WritableStreamInterface $stream) use (&$file, $dataSr) {
                $stream->write($dataSr);
                return $file->close();
            }
        )->then(null, function($error = null) {
            $message = $error instanceof \Throwable
                ? $error->getMessage() . "\n" . $error->getFile() . ' #' . $error->getLine() : $error;
            \Reaction::error($message);
            return false;
        });
        return resolve($writePromise);
    }
public function set($id, $data)
    {
        $dataSr = $this->getHandler()->serializeData($data);
        /** @var File $file */
        $file = null;
        $createMode = FileHelperAsc::permissionsAsString(0777);
        $writePromise = $this->getArchiveFilePath($id)->then(
            function($filePath) use (&$file) {
                $file = \Reaction::$app->fs->file($filePath);
                return \Reaction::$app->fs->file($filePath)->exists();
            }
        )->then(null,
            function() use (&$file, $createMode) { return $file->create($createMode); }
        )->then(
            function() use (&$file) { return $file->open('w'); }
        )->then(
            function(WritableStreamInterface $stream) use (&$file, $dataSr) {
                $stream->write($dataSr);
                return $file->close();
            }
        )->then(null, function($error = null) {
            $message = $error instanceof \Throwable
                ? $error->getMessage() . "\n" . $error->getFile() . ' #' . $error->getLine() : $error;
            \Reaction::error($message);
            return false;
        });
        return resolve($writePromise);
    }
Save data to archive
@param string $id
@param array  $data
@return ExtendedPromiseInterface which resolved after save complete