public function cookieDomain(UriInterface $uri): ?string
    {
        $host = $uri->getHost();
        if (empty($host)) {
            return null;
        }

        $pattern = $this->config['cookies']['domain'];
        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
            // remove port
            $host = $matches[1];
        }

        if (filter_var($host, FILTER_VALIDATE_IP) || $host == 'localhost') {
            //We can't use sub-domains when website required by IP
            $pattern = ltrim($pattern, '.');
        }

        if (strpos($pattern, '%s') === false) {
            //Forced domain
            return $pattern;
        }

        return sprintf($pattern, $host);
    }
public function cookieDomain(UriInterface $uri): ?string
    {
        $host = $uri->getHost();
        if (empty($host)) {
            return null;
        }

        $pattern = $this->config['cookies']['domain'];
        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
            // remove port
            $host = $matches[1];
        }

        if (filter_var($host, FILTER_VALIDATE_IP) || $host == 'localhost') {
            //We can't use sub-domains when website required by IP
            $pattern = ltrim($pattern, '.');
        }

        if (strpos($pattern, '%s') === false) {
            //Forced domain
            return $pattern;
        }

        return sprintf($pattern, $host);
    }
public function cookieDomain ( UriInterface $ uri ) : ? string { $ host = $ uri -> getHost ( ) ; if ( empty ( $ host ) ) { return null ; } $ pattern = $ this -> config [ 'cookies' ] [ 'domain' ] ; if ( preg_match ( "/^(\d{1,3}){4}:\d+$/" , $ host , $ matches ) ) { // remove port $ host = $ matches [ 1 ] ; } if ( filter_var ( $ host , FILTER_VALIDATE_IP ) || $ host == 'localhost' ) { //We can't use sub-domains when website required by IP $ pattern = ltrim ( $ pattern , '.' ) ; } if ( strpos ( $ pattern , '%s' ) === false ) { //Forced domain return $ pattern ; } return sprintf ( $ pattern , $ host ) ; }
Return domain associated with the cookie.

@param UriInterface $uri

@return string|null
Return domain associated with the cookie .