function checkSessionStatus() {
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState === XMLHttpRequest.DONE) {
            if (xhr.status === 200) {
                // Session is still active, do nothing
            } else {
                // Session has expired, redirect to login page
                window.location.href = '/login.php?error=timeCompleted';
            }
        }
    };
    xhr.open('GET', '/include/helper_functions/checkSession.php', true);
    xhr.send();
}

// Call checkSessionStatus() every second
setInterval(checkSessionStatus, 30000);
