Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies not set when port is used in URL #11

Open
LRP-sgravel opened this issue Jun 22, 2016 · 1 comment
Open

Cookies not set when port is used in URL #11

LRP-sgravel opened this issue Jun 22, 2016 · 1 comment

Comments

@LRP-sgravel
Copy link

My CI test webserver is on port 8000 so my tests continually failed but only on this server. The reason is that Firefox doesn't set cookies when there is a port in the domain. I'm not sure what other browsers could be affected.

I didn't want to fork for this simple fix but here it is for Experiments.php (notice the addition of a parse_url call when using $_SERVER):

    /**
     * @return string
     */
    public static function getDomainName() {
        if(static::$domainName == 'auto') {
            return isset($_SERVER['HTTP_HOST']) ? parse_url(strtolower($_SERVER['HTTP_HOST']), PHP_URL_HOST) : null;
        } elseif(static::$domainName) {
            return static::$domainName;
        } else {
            throw new UnexpectedValueException('Unable to determine domain name, please provide one via setDomainName()!');
        }
    }
@LRP-sgravel
Copy link
Author

Sorry, it should have been:

return isset($_SERVER['HTTP_HOST']) ? parse_url(strtolower('http://' . $_SERVER['HTTP_HOST']), PHP_URL_HOST) : null;

Missing 'http://' prefix messes up parse_url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant