<?php

declare(strict_types=1);

function fate_public_session_start(): void
{
    if (session_status() === PHP_SESSION_ACTIVE) {
        if (session_name() === 'fate_site') {
            fate_session_keep_alive();

            return;
        }
        if (!headers_sent()) {
            session_write_close();
        } else {
            return;
        }
    }

    if (headers_sent()) {
        return;
    }

    if (!function_exists('fate_session_apply_options')) {
        require_once __DIR__ . DIRECTORY_SEPARATOR . 'fate_member_session_bridge.php';
    }

    fate_session_apply_options();

    session_name('fate_site');
    session_start();
    fate_session_finalize_start();
}
