<?php
// refresh_session.php

// Start or resume the session
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Set appropriate response headers
header('Content-Type: application/json');

// Check if user session is active
if (isset($_SESSION['user_id'])) {
    // Refresh session activity timestamp
    $_SESSION['last_activity'] = time();

    echo json_encode([
        'success' => true,
        'message' => 'Session refreshed.'
    ]);
} else {
    // Session does not exist or has expired
    echo json_encode([
        'success' => false,
        'message' => 'No active session.'
    ]);
}
?>
