<?php
require_once 'auth.php';

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

if (empty($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
    http_response_code(401);
    echo json_encode(['ok' => false, 'message' => 'not_logged_in']);
    exit();
}

if (isSessionExpired()) {
    destroyActiveSession();
    http_response_code(401);
    echo json_encode(['ok' => false, 'message' => 'expired']);
    exit();
}

$_SESSION['last_activity'] = time();

echo json_encode([
    'ok' => true,
    'timeout' => SESSION_IDLE_TIMEOUT
]);
