core-bundle/src/HttpKernel/JwtManager.php
public function addResponseCookie(Response $response, array $payload = []): void
    {
        if ($this->hasCookie($response)) {
            return;
        }

        $payload['iat'] = time();
        $payload['exp'] = strtotime('+30 minutes');

        if (method_exists(Cookie::class, 'create')) {
            $cookie = Cookie::create(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
        } else {
            // Backwards compatibility with symfony/http-foundation <4.2
            $cookie = new Cookie(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
        }

        $response->headers->setCookie($cookie);
    }
public function addResponseCookie(Response $response, array $payload = []): void
    {
        if ($this->hasCookie($response)) {
            return;
        }

        $payload['iat'] = time();
        $payload['exp'] = strtotime('+30 minutes');

        if (method_exists(Cookie::class, 'create')) {
            $cookie = Cookie::create(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
        } else {
            // Backwards compatibility with symfony/http-foundation <4.2
            $cookie = new Cookie(self::COOKIE_NAME, JWT::encode($payload, $this->secret));
        }

        $response->headers->setCookie($cookie);
    }
public function addResponseCookie ( Response $ response , array $ payload = [ ] ) : void { if ( $ this -> hasCookie ( $ response ) ) { return ; } $ payload [ 'iat' ] = time ( ) ; $ payload [ 'exp' ] = strtotime ( '+30 minutes' ) ; if ( method_exists ( Cookie :: class , 'create' ) ) { $ cookie = Cookie :: create ( self :: COOKIE_NAME , JWT :: encode ( $ payload , $ this -> secret ) ) ; } else { // Backwards compatibility with symfony/http-foundation <4.2 $ cookie = new Cookie ( self :: COOKIE_NAME , JWT :: encode ( $ payload , $ this -> secret ) ) ; } $ response -> headers -> setCookie ( $ cookie ) ; }
Adds the JWT cookie to the given response.
Adds the JWT cookie to the given response .