title: Is this a proper way to destroy all session data in php?
body: <p>Got it from php.net, but I am not sure is this how everybody destroy all sessions?</p>
  
  <pre><code>// Unset all Sessions
  $_SESSION = array();
  
  if (isset($_COOKIE[session_name()])) {
      setcookie(session_name(), '', time() -42000, '/');
  }
  
      session_destroy();
  </code></pre>
  
  <p>Does the code will destroy all the sessions?? Is it the most common way? how do you guys destroy php sessions?</p>
  
  <p>Oh yeah, btw, what is that <code>session_name()</code>? All session name? e.g <code>$_SESSION['var1']</code>, <code>$_SESSION['var2']</code>, ...  ?</p>
  
  <p>I dont need to use <code>unset($_SESSION['var1']);</code> any more right?</p>
  
  <p>Whats the different between using <code>session_destroy()</code> and <code>unset($_SESSION[])</code>?</p>