ajax要求加载不在每个浏览器中运行的广告

I have this ajax function to show a nivo slider based overlay with some images. I want to load the ads for every page, but only once per hour (so the ads pop up on the first visit, and then an hour later when you refresh). This function works in Chrome, IE, but doesn't work in Firefox for some reason, I have to refresh again in FF or get to a subpage for the ads to load: The function:

session_start();

require_once dirname(__FILE__) . '/../../admin/lib/config/config.inc.php';

$_SESSION['last_refresh'] = date("d-m-Y H:i:s");

$diff = strtotime($_SESSION['last_refresh']) -  strtotime($_SESSION['ad_datetime']);


 if(empty($_SESSION['ad_datetime'])) {
     $c = 1;
     $_SESSION['ad_datetime'] = date("d-m-Y H:i:s");
 } else {
     if($diff > 3600) {
        $c = 1;
        $_SESSION['ad_datetime'] = date("d-m-Y H:i:s");
     } else {
        $c = 0;
     }
 }


echo $c;

The $c = 1; is the response for the javascript file to load the ad. If the response is 0 it does nothing.

Try changing your code like this

if(empty($_SESSION['ad_datetime']) || $diff > 3600) {
     $c = 1;
     $_SESSION['ad_datetime'] = date("d-m-Y H:i:s");
 } else {
        $c = 0;
 }