<?php
  declare(strict_types=1);
  // BEFORE session_start()
  ini_set('session.cookie_path', '/');

  // If you already call session_set_cookie_params(), ensure path is '/'
  session_set_cookie_params([
    'path' => '/',
    'httponly' => true,
    'samesite' => 'Lax',
    // 'secure' => true, // enable if you use HTTPS
  ]);

  session_start();

$configPath = __DIR__ . '/config.php';
if (!file_exists($configPath)) {
  http_response_code(500);
  echo "Missing app/config.php. Copy app/config.sample.php to app/config.php and configure.";
  exit;
}
$config = require $configPath;

require_once __DIR__ . '/lib/Db.php';
require_once __DIR__ . '/lib/Auth.php';
require_once __DIR__ . '/lib/Helpers.php';

$db = Db::pdo($config['db']);
$auth = new Auth($db);
