title: how unset session when close the web page in php
body: <p>How can I unset the SESSION when I close the page by clicking [x] (not onunload). I want to insert when opening the page and when closing, but I don't want to insert when refreshing.</p>
  
  <pre><code>if (!isset($_SESSION["visits"]))
      $_SESSION["visits"] = 0;
      $_SESSION["visits"] = $_SESSION["visits"] + 1;
  if ($_SESSION["visits"] &gt; 1){echo "You hit the refresh button!";}
  else{
      mysql_query(
          "INSERT INTO najd_visit( visit_userId, visit_staticId, visit_page,
              visit_enterTime)VALUES ('$userId', '$Sid', '$title', '$date') ");
      echo "This is my site";
      //unset($_SESSION["visits"]);
  }
  </code></pre>