title: if not logged in redirect after 6 page counts?
body: <p>I am trying to get this script to work properly but am not having any luck, please can someone show me what i need to do.</p>
  
  <p>At the moment the script counts the number of times a page has been accessed and redirects the user to another page if the count reaches 6. </p>
  
  <p>It should only redirect if the user is not logged in, but instead it is also redirecting users when they are logged in. Please can someone show me where im going wrong.</p>
  
  <p>Thanks.    </p>
  
  <pre><code>&lt;?
      !session_id() ? session_start() : null;
  
      if(!isset($_SESSION['logged_in']) &amp;&amp; empty($_SESSION['logged_in'])){
          verify_profile_visit_limit();
      }
  
      function verify_profile_visit_limit(){
          $free_profiles = array(99999,99998,99997,99996,99995,99994,99993);
  
          if(in_array($_GET["id"], $free_profiles)) return;
  
          if(! isset($_SESSION["page_access_count"])){
              $_SESSION["page_access_count"] = 1;
          }
  
          $_SESSION["page_access_count"]++;
  
          if($_SESSION["page_access_count"] &gt; 6){
              header("Location: limit.php");
              exit();
          }
      }
  
      ?&gt;
  </code></pre>