src/Viserio/Component/Session/Middleware/VerifyCsrfTokenMiddleware.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (! $request->getAttribute('session') instanceof StoreContract) {
            throw new SessionNotStartedException('The session is not started.');
        }

        $response = $handler->handle($request);

        if ($this->isReading($request) ||
            $this->runningUnitTests() ||
            $this->tokensMatch($request)
        ) {
            return $this->addCookieToResponse($request, $response);
        }

        throw new TokenMismatchException();
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (! $request->getAttribute('session') instanceof StoreContract) {
            throw new SessionNotStartedException('The session is not started.');
        }

        $response = $handler->handle($request);

        if ($this->isReading($request) ||
            $this->runningUnitTests() ||
            $this->tokensMatch($request)
        ) {
            return $this->addCookieToResponse($request, $response);
        }

        throw new TokenMismatchException();
    }
{@inheritdoc}

@throws \Viserio\Component\Contract\Session\Exception\SessionNotStartedException
@throws \Viserio\Component\Contract\Session\Exception\TokenMismatchException