public function engine($class = null, array $options = [])
    {
        if ($class === null) {
            return $this->_engine;
        }
        if ($class instanceof SessionHandlerInterface) {
            return $this->setEngine($class);
        }
        $className = App::className($class, 'Http/Session');

        if (!$className) {
            $className = App::className($class, 'Network/Session');
            if ($className) {
                deprecationWarning('Session adapters should be moved to the Http/Session namespace.');
            }
        }
        if (!$className) {
            throw new InvalidArgumentException(
                sprintf('The class "%s" does not exist and cannot be used as a session engine', $class)
            );
        }

        $handler = new $className($options);
        if (!($handler instanceof SessionHandlerInterface)) {
            throw new InvalidArgumentException(
                'The chosen SessionHandler does not implement SessionHandlerInterface, it cannot be used as an engine.'
            );
        }

        return $this->setEngine($handler);
    }