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

Remove default value for cookies_domain #6440

Merged
merged 1 commit into from
Mar 2, 2017
Merged
Changes from all commits
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
26 changes: 0 additions & 26 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,32 +345,6 @@ protected function parseGeneral()
// Merge the array with the defaults. Setting the required values that aren't already set.
$general = Arr::mergeRecursiveDistinct($this->defaultConfig, $general);

// Make sure the cookie_domain for the sessions is set properly.
if (empty($general['cookies_domain'])) {
$request = Request::createFromGlobals();
if ($request->server->get('HTTP_HOST', false)) {
$hostSegments = explode(':', $request->server->get('HTTP_HOST'));
$hostname = reset($hostSegments);
} elseif ($request->server->get('SERVER_NAME', false)) {
$hostname = $request->server->get('SERVER_NAME');
} else {
$hostname = '';
}

// Don't set the domain for a cookie on a "TLD" - like 'localhost', or if the server_name is an IP-address
if ((strpos($hostname, '.') > 0) && preg_match('/[a-z0-9]/i', $hostname)) {
if (preg_match('/^www[0-9]*./', $hostname)) {
$general['cookies_domain'] = '.' . preg_replace('/^www[0-9]*./', '', $hostname);
} else {
$general['cookies_domain'] = '.' . $hostname;
}
// Make sure we don't have consecutive '.'-s in the cookies_domain.
$general['cookies_domain'] = str_replace('..', '.', $general['cookies_domain']);
} else {
$general['cookies_domain'] = '';
}
}

// Make sure Bolt's mount point is OK:
$general['branding']['path'] = '/' . Str::makeSafe($general['branding']['path']);

Expand Down