public function onSessionReadEvent()
    {
        return function ($sessionEvent) {
            /** @var \PHPDaemon\Core\DeferredEvent $sessionEvent */
            $name = ini_get('session.name');
            $sid = $this->getCookieStr($name);
            if ($sid === '') {
                $sessionEvent->setResult(false);
                return;
            }
            if ($this->getSessionState() !== null) {
                $sessionEvent->setResult(true);
                return;
            }
            $this->sessionRead($sid, function ($data) use ($sessionEvent, $sid) {
                $canDecode = $data !== false && $this->sessionDecode($data);
                $sessionEvent->setResult($canDecode);
            });
        };
    }