<?php
session_start();
require_once(dirname(__DIR__, 1) . '/config.php');
require_once(BASE_PATH . '/db/idl_connect.php');
if (isset($_SESSION['user_id']) && isset($prefix)) {
    $stmt = $pdo->prepare("
        DELETE FROM {$prefix}_userconnect
        WHERE user_id = :uid
    ");
    $stmt->execute([
        ':uid' => $_SESSION['user_id']
    ]);
}

$_SESSION['essai_con'] = $_SESSION['essai_con'] ?? 0;
$_SESSION['essai_res'] = $_SESSION['essai_res'] ?? 0;
$_SESSION['max_reserv'] = $_SESSION['max_reserv'] ?? 0;
$_SESSION = array('essai_con' => $_SESSION['essai_con'], 'essai_res' => $_SESSION['essai_res'], 'max_reserv' => $_SESSION['max_reserv']);

if (isset($bdd) && $bdd instanceof mysqli) {
    mysqli_close($bdd);
}
// redirection propre (mieux que JS)
header("Location: ../index.php");
exit;
?>