I added the time check, and that improved the problem greatly, but not totally.
if(!isset($_SESSION['headerphotonum'])) { $_SESSION['headerphotonum']=-1; }
if(!isset($_SESSION['headerphotochanged'])) {
$date = new DateTime();
$_SESSION['headerphotochanged']=$date->getTimestamp();
}
$date = new DateTime();
if($date->getTimestamp()>($_SESSION['headerphotochanged']+3)) {
$_SESSION['headerphotonum']=$_SESSION['headerphotonum']+1;
$date = new DateTime();
$_SESSION['headerphotochanged']=$date->getTimestamp();
}
That didn't completely fix the problem. The number would go up just 1, unless I waited a longer time. After six seconds, it went up 2. Waiting for 10 or more seconds to refresh, and it went up 3. That's still pretty weird.
Then I watched the loading log and tracked down all missing images (I'm creating a new site based on an old one, so there were number of these). I fixed all that so that there no loading errors, and the increment now works properly. So it does look like the browser is sending requests back to the server when it doesn't find an image, and that triggers the script to rerun. No loading errors, and the script only runs once. So, I suspect you have some file missing on your local install that is causing the browser to fetch the page more than once.
[ed. note: rainbowtiger last edited this post 12 years, 6 months ago.]