diff --git a/src/Codeception/Coverage/Subscriber/LocalServer.php b/src/Codeception/Coverage/Subscriber/LocalServer.php index 259d655a8b..86e9bc33e3 100644 --- a/src/Codeception/Coverage/Subscriber/LocalServer.php +++ b/src/Codeception/Coverage/Subscriber/LocalServer.php @@ -201,8 +201,13 @@ protected function startCoverageCollection($testName) // we need to separate coverage cookies by host; we can't separate cookies by port. $cookieDomain = isset($c3Url['host']) ? $c3Url['host'] : 'localhost'; } + + $cookieParams = []; + if ($cookieDomain !== 'localhost') { + $cookieParams['domain'] = $cookieDomain; + } - $this->module->setCookie(self::COVERAGE_COOKIE, $value, ['domain' => $cookieDomain]); + $this->module->setCookie(self::COVERAGE_COOKIE, $value, $cookieParams); // putting in configuration ensures the cookie is used for all sessions of a MultiSession test