title: How to execute php code once on single page view
body: <p>I have a web page on which four ads are displayed using different ad code for each advertisement. This ad code records website hit and ad impression in two different mysql tables on every time this code is executed. </p>
  
  <p>But my problem is that as i have installed four ads on single web page. whenever this web page is loaded each ad code records website hit in table and ad impression in another table. I want to record website hit once for single web page view whether there exists one ad or more ads. How to do this?</p>
  
  <p>I tried to use session cookie as give below</p>
  
  <pre><code>if(isset($_COOKIE['userstatus'])){
      $oldnew = "old";
  }
  else
  {
      $oldnew = "new";    
  }
  
  //SESSION DOES NOT EXISTS USER IS NEW AD ROW, IF USER IS OLD DO NOTHING
  if(($oldnew == 'new')) {
  
  $stmt = $conn-&gt;prepare("INSERT INTO webimps (zoneweb, session, time, ref, device, visitorip, os, oldnew, browser, wview) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  $stmt-&gt;bind_param("ssssssssss", $web, $session, $time, $ref, $device, $ip, $user_os, $oldnew, $user_browser, $one);
  $stmt-&gt;execute();
  $stmt-&gt;close();
  
  }
  </code></pre>
  
  <p>But this also did not worked, Website hit is recorded by each ad code on single page view.</p>