protected function decrypt(ServerRequestInterface $request): ServerRequestInterface
    {
        $cookies = RequestCookies::fromRequest($request);

        /** @var Cookie $cookie */
        foreach ($cookies->getAll() as $cookie) {
            $name = $cookie->getName();

            if ($this->isDisabled($name)) {
                continue;
            }

            try {
                $decryptedValue = Crypto::decrypt($cookie->getValue(), $this->key);
                $cookies        = $cookies->forget($name);
                $cookie         = $cookie->withValue($decryptedValue->getString());

                $cookies = $cookies->add($cookie);
            } catch (InvalidMessage $exception) {
                $cookies = $cookies->add(new Cookie($name, null));
            }
        }

        return $cookies->renderIntoCookieHeader($request);
    }
protected function decrypt(ServerRequestInterface $request): ServerRequestInterface
    {
        $cookies = RequestCookies::fromRequest($request);

        /** @var Cookie $cookie */
        foreach ($cookies->getAll() as $cookie) {
            $name = $cookie->getName();

            if ($this->isDisabled($name)) {
                continue;
            }

            try {
                $decryptedValue = Crypto::decrypt($cookie->getValue(), $this->key);
                $cookies        = $cookies->forget($name);
                $cookie         = $cookie->withValue($decryptedValue->getString());

                $cookies = $cookies->add($cookie);
            } catch (InvalidMessage $exception) {
                $cookies = $cookies->add(new Cookie($name, null));
            }
        }

        return $cookies->renderIntoCookieHeader($request);
    }
protected function decrypt ( ServerRequestInterface $ request ) : ServerRequestInterface { $ cookies = RequestCookies :: fromRequest ( $ request ) ; /** @var Cookie $cookie */ foreach ( $ cookies -> getAll ( ) as $ cookie ) { $ name = $ cookie -> getName ( ) ; if ( $ this -> isDisabled ( $ name ) ) { continue ; } try { $ decryptedValue = Crypto :: decrypt ( $ cookie -> getValue ( ) , $ this -> key ) ; $ cookies = $ cookies -> forget ( $ name ) ; $ cookie = $ cookie -> withValue ( $ decryptedValue -> getString ( ) ) ; $ cookies = $ cookies -> add ( $ cookie ) ; } catch ( InvalidMessage $ exception ) { $ cookies = $ cookies -> add ( new Cookie ( $ name , null ) ) ; } } return $ cookies -> renderIntoCookieHeader ( $ request ) ; }
Decrypt the cookies on the request.

@param \Psr\Http\Message\ServerRequestInterface $request

@return \Psr\Http\Message\ServerRequestInterface
Decrypt the cookies on the request .