Hey again! I'm trying to write a set of scripts that will run on a page only if it has been more than 15 minutes since they last ran. Basically, an automated script updates a database of mine every half hour--and a page which displays that information and updates session variables must obviously query the database whenever it is opened.
So in order to minimize queries but also stay on the safe side, I figured that the session variables would only be updated from the database if it had been more than fifteen minutes since that page was last viewed. I wrote up some code, and I was hoping you guys could take a look at it before I try implementing it?
if(!isset($_SESSION['time_next'])){
$_SESSION['time_next'] = time() + (15 * 60);
//15 minutes
}
else if(time() >= $_SESSION['time_next']){
//update all the session variables, etc...
$_SESSION['time_next'] = time() + (15 * 60);
}
What do you think? Will this work?