<?php
/**
 * Session Check API
 */
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/session_boot.php';

header('Content-Type: application/json');

if (isset($_SESSION['user_id']) && $_SESSION['user_status'] === 'active') {
    echo json_encode([
        'authenticated' => true, 
        'user' => [
            'id' => $_SESSION['user_id'],
            'name' => $_SESSION['user_full_name'],
            'role' => $_SESSION['user_role'],
            'unit' => $_SESSION['unit_name']
        ]
    ]);
} else {
    echo json_encode(['authenticated' => false]);
}
?>