diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index 71b6df4..91b57be 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -114,4 +114,4 @@ jobs: continue-on-error: true run: | bin/console cache:warmup --env=test - vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src/I18nBundle --config ${{ github.workspace }}/lib/test-bundle/ecs.php \ No newline at end of file + vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src/ --config ${{ github.workspace }}/lib/test-bundle/ecs.php \ No newline at end of file diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2e43e42..ab84655 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -160,7 +160,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->booleanNode('httpOnly') ->defaultTrue() ->end() - ->scalarnode('sameSite') + ->scalarNode('expire') + ->defaultValue('+1 year') + ->end() + ->scalarNode('sameSite') ->defaultValue(Cookie::SAMESITE_LAX) ->validate() ->ifNotInArray([Cookie::SAMESITE_NONE, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT]) diff --git a/src/Helper/CookieHelper.php b/src/Helper/CookieHelper.php index 5292d1f..3b99a7f 100644 --- a/src/Helper/CookieHelper.php +++ b/src/Helper/CookieHelper.php @@ -48,9 +48,10 @@ public function set(Response $response, array $params): Cookie $secure = $cookieConfig['secure']; $httpOnly = $cookieConfig['httpOnly']; $sameSite = $cookieConfig['sameSite']; + $expire = is_string($cookieConfig['expire']) ? strtotime($cookieConfig['expire']) : $cookieConfig['expire']; $cookieData = base64_encode(json_encode($params)); - $cookie = new Cookie(Definitions::REDIRECT_COOKIE_NAME, $cookieData, strtotime('+1 year'), $path, $domain, $secure, $httpOnly, false, $sameSite); + $cookie = new Cookie(Definitions::REDIRECT_COOKIE_NAME, $cookieData, $expire, $path, $domain, $secure, $httpOnly, false, $sameSite); $response->headers->setCookie($cookie); return $cookie;