<?php
declare(strict_types=1);

/**
 * Shared session for all Android Cast web consoles (crashes, build, …).
 * Same cookie path + session name => one login across sub-apps.
 */
function platform_start_session(string $sessionName = 'ac_crash_sess', string $cookiePath = '/app/androidcast_project'): void
{
    if (session_status() === PHP_SESSION_ACTIVE) {
        return;
    }
    session_name($sessionName);
    session_set_cookie_params([
        'lifetime' => 0,
        'path' => $cookiePath,
        'httponly' => true,
        'samesite' => 'Lax',
        'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'),
    ]);
    session_start();
}
