<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

require_once __DIR__ . '/../db/config.php';

function is_logged_in() {
    return isset($_SESSION['user_id']);
}

function get_logged_in_user_id() {
    return $_SESSION['user_id'] ?? null;
}

function login_user($user_id) {
    $_SESSION['user_id'] = $user_id;
}

function logout_user() {
    unset($_SESSION['user_id']);
    session_destroy();
}
