'session.cookie_domain' is not a valid sessions-related ini setting

We have upgraded PHP version to 8.2.1 from 7.1.33. When we run PHPUnit tests, it gives the below errors:

Laminas\Session\Exception\InvalidArgumentException: 'session.name' is not a valid sessions-related ini setting. in vendor/laminas/laminas-session/src/Config/SessionConfig.php:187

Laminas\Session\Exception\InvalidArgumentException: 'session.cookie_domain' is not a valid sessions-related ini setting. in vendor/laminas/laminas-session/src/Config/SessionConfig.php:187

composer.json:

"require": {
    "php": "~8.2",
    "doctrine/dbal": "~3.5.3",
    "predis/predis": "^1.1",
    "laminas/laminas-session": "^2.16",
    "laminas/laminas-cache": "^3.10",
    "cytec/laminas-cache-predis": "^2.0.0",
    "psr/http-server-middleware": "^1.0",
    "psr/http-factory": "^1.0",
    "php-http/guzzle6-adapter": "^2.0"
  },
  "require-dev": {
    "phpunit/phpunit": "^9.5",
    "squizlabs/php_codesniffer": "^3.7",
    "phpstan/phpstan": "^1.9",
    "phpstan/extension-installer": "^1.2",
    "phpstan/phpstan-phpunit": "^1.3",
    "symfony/phpunit-bridge": "^6.2",
    "symfony/var-dumper": "^6.2",
    "symfony/dotenv": "^6.2",
    "symfony/yaml": "^6.2",
    "laminas/laminas-validator": "^2.13"
  }

The issue is related to ini_set() of session variables called via setCookieDomain/setName methods. This worked fine with PHP 7.1, phpunit/phpunit 7.5, and laminas/laminas-session 2.9.

Can anyone please help me with this?

Do you set some configuration for laminas-session, like cookie_domain or name ? If so, what does this look like?

We use the below configuration:

$sessionConfig = new SessionConfig();
$sessionConfig
    ->setUseCookies(true)
    ->setName('abcd')
    ->setCookieDomain('.test-domain.com');
    
new SessionManager($sessionConfig);

This looks good and also works outside of unit tests, so the problem is probably in the test setup.

Yes. If we call ini_set(‘session.name’, ‘abcd’) from PHPUnit setUpBeforeClass() gives the same error.