what is better to logout in php?
<p>i am having a debate on what would be a better method for loging out in php , if someone could help me clarify i would be most gratefull : </p>

<p>I have two versions of the code for log out </p>

<p>1 ) </p>

<pre><code>$logoutGoTo = "login.php";
if (!isset($_SESSION)) {
  session_start();
}
$_SESSION['username'] = NULL;
$_SESSION['user_id'] = NULL;
unset($_SESSION['username']);
unset($_SESSION['user_id']);
$_SESSION = array();
if ($logoutGoTo != "") {header("Location: $logoutGoTo");
exit;
</code></pre>

<p>2)</p>

<pre><code>session_start();
    session_unset();
session_destroy();
</code></pre>

<p>Which is the better solution?</p>
