Cooper94 Posted December 6, 2009 Share Posted December 6, 2009 Is it possible to have a script check every minute to make sure the user is still online? <?php $inactive = 60; if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive) { mysql_query("UPDATE pilots SET online = '0' WHERE callsign = '$_SESSION[username]'"); }} $_SESSION['timeout'] = time(); mysql_query("UPDATE pilots SET online = '1' WHERE callsign = '$_SESSION[username]'"); ?> This does the tick but the client needs to refresh the page to online = 0. Is it possible to have it go to 0 before they refresh? So that when they do refresh the page from being back it will than upate the status to online = 1? Thank you for your time and all your help! Quote Link to comment Share on other sites More sharing options...
greatstar00 Posted December 6, 2009 Share Posted December 6, 2009 u can combine your mysql session, and cron job but your need to change your code a bit Quote Link to comment Share on other sites More sharing options...
Cooper94 Posted December 6, 2009 Author Share Posted December 6, 2009 Is there any way you can help me out? Thank You Quote Link to comment Share on other sites More sharing options...
greatstar00 Posted December 6, 2009 Share Posted December 6, 2009 does your server support cron job? Quote Link to comment Share on other sites More sharing options...
Cooper94 Posted December 6, 2009 Author Share Posted December 6, 2009 Yes, sir Quote Link to comment Share on other sites More sharing options...
Cooper94 Posted December 9, 2009 Author Share Posted December 9, 2009 I know this is old but I did setup a cron job for a script that runs and checks to see if the user has reached its limit but it does not work. But if I go to the url the script is located on it will update the database no problem! Below is my script: <?php include '../includes/db.php'; session_start(); $inactive = 60; if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive) { mysql_query("UPDATE pilots SET online = '0' WHERE callsign = '$_SESSION[username]'"); }} ?> The $_SESSION['timeout'] is a vairable that that equavilant to time() which is set when the person refreshs any page on the site, I have tested that in an echo and it is outputing a number. Like I said it does work when I go to the script location in my browser. Any help would be great! Thank You Quote Link to comment Share on other sites More sharing options...
Cooper94 Posted December 9, 2009 Author Share Posted December 9, 2009 *bump* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.