session_start();
if (isset($_POST['check'])) {
exit(isset($_SESSION['gelen']) ? 'var' : 'yok');
}



<script>
$(document).ready(function () {
let interval = setInterval(() => {
$.post(window.location, {
check: true
}, function (response) {
if (response === 'var') {
clearInterval(interval);
// $("#Modal").modal('show');
console.log('Modal açılsın')
}
});
}, 3000)
})
</script>