You need to have 2 pages:
- The page your users access (also the page you add the jQuery code below)
- The page which reads your database and prints out true/false (Which in the example below, I am naming it as "your_check_login_url.php".)
The jQuery code on page 1 will read page 2 without refreshing page 1. You then use Javascript to update what you need on page 1.
Using jQuery:
<script>
var tid = setTimeout(checkLogin, 5000);
function checkLogin() {
$.get( "your_check_login_url.php", function( data ) {
alert(data.is_logged_in); // Replace with your own code
});
tid = setTimeout(checkLogin, 5000); // repeat myself
}
</script>
And on the PHP side return a value JSON or otherwise which your Javascript can read as true/false.
<?php
$logged_in = TRUE; //Replace with your PHP/MySQL code to check if log in is true
header('Content-Type: application/json');
echo json_encode(
array('is_logged_in' => $logged_in)
);