<?php
// ajax/ping_session.php
session_start();
include '../config/security_config.php';

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

if (isset($_SESSION['user_id'])) {
    // Check if session is still valid
    if (isset($_SESSION['last_activity']) && 
        (time() - $_SESSION['last_activity']) < SESSION_TIMEOUT) {
        echo json_encode(['success' => true, 'active' => true]);
    } else {
        echo json_encode(['success' => false, 'active' => false, 'message' => 'Session expired']);
    }
} else {
    echo json_encode(['success' => false, 'active' => false, 'message' => 'No session']);
}
?>