diff --git a/index.php b/index.php index 3ace3f6e..637e321c 100644 --- a/index.php +++ b/index.php @@ -37,9 +37,30 @@ spl_autoload_register( } ); +/** + * Config + */ +$configPath = __DIR__ . '/' . 'src/config/config.php'; + +if (file_exists($configPath)) { + require $configPath; +} + /** * Session */ +$cookie_domain = $_SERVER['HTTP_HOST']; + +if (defined('CHANNELS') && is_iterable(CHANNELS)) { + foreach (CHANNELS as $channel) { + if ('stable' === $channel['branch']) { + $cookie_domain = $channel['host']; + + break; + } + } +} + $sessionLifetime = 2592000 * 12; // 12 Months session_start( @@ -47,7 +68,7 @@ session_start( 'name' => 'wishthis', 'cookie_lifetime' => $sessionLifetime, 'cookie_path' => '/', - 'cookie_domain' => '.wishthis.online', + 'cookie_domain' => '.' . $cookie_domain, ) ); @@ -56,15 +77,6 @@ if (!isset($_SESSION['user']) || is_array($_SESSION['user'])) { $_SESSION['user'] = new User(); } -/** - * Config - */ -$configPath = __DIR__ . '/' . 'src/config/config.php'; - -if (file_exists($configPath)) { - require $configPath; -} - /** * Database */