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

Fix domain cookie value with http port #5115

Merged
merged 2 commits into from
Apr 6, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ protected function parseGeneral()

// Make sure the cookie_domain for the sessions is set properly.
if (empty($general['cookies_domain'])) {
if (isset($_SERVER['HTTP_HOST'])) {
$hostname = $_SERVER['HTTP_HOST'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
if (isset($_SERVER['SERVER_NAME'])) {
$hostname = $_SERVER['SERVER_NAME'];
} elseif (isset($_SERVER['HTTP_HOST'])) {
$hostname = reset(explode(':', $_SERVER['HTTP_HOST']));
} else {
$hostname = '';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to go for something like:

            $request = Request::createFromGlobals();
            if ($request->server->get('HTTP_HOST', false)) {
                $hostHeaders = explode(':', $request->server->get('HTTP_HOST'));
                $hostname = reset($hostHeaders);
            } elseif ($request->server->get('SERVER_NAME', false)) {
                $hostname = $request->server->get('SERVER_NAME');
            } else {
                $hostname = '';
            }

Expand Down