How to create a php script which make function run in background? -
i want create function runs in background. example deleting session database (id,session_token, session_identifier, expired_time). once it's expire current page automatically redirect user login page (login.php).
update
the expired time stored in database.
you can using jquery ajax , setinterval function
function check_login() { $.ajax({ type: 'get', url: "http://stackoverflow.com", /*where check user logged in or not means session expired or not*/ beforesend: function(xhr) { xhr.setrequestheader('content-type', 'application/x-www-form-urlencoded'); }, success: function(response) { /*ajax call return "still login" (or other response) if login*/ if (response == 'still login') { return true; } else if (response == 'not login') { window.location.replace("http://domain.com/login.php"); } } }); } setinterval(check_login, 100);
Comments
Post a Comment