//set cookie setcookie($imageid, "Viewed"); //if not viewed before then update hits if (!isset($_COOKIE['$imageid'])) {