Fix hard coded cookie_domain

This commit is contained in:
grandeljay 2022-09-22 16:37:24 +02:00
parent 5ae647ebf5
commit 7d5fe7eadc

View file

@ -37,9 +37,30 @@ spl_autoload_register(
} }
); );
/**
* Config
*/
$configPath = __DIR__ . '/' . 'src/config/config.php';
if (file_exists($configPath)) {
require $configPath;
}
/** /**
* Session * 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 $sessionLifetime = 2592000 * 12; // 12 Months
session_start( session_start(
@ -47,7 +68,7 @@ session_start(
'name' => 'wishthis', 'name' => 'wishthis',
'cookie_lifetime' => $sessionLifetime, 'cookie_lifetime' => $sessionLifetime,
'cookie_path' => '/', '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(); $_SESSION['user'] = new User();
} }
/**
* Config
*/
$configPath = __DIR__ . '/' . 'src/config/config.php';
if (file_exists($configPath)) {
require $configPath;
}
/** /**
* Database * Database
*/ */