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 :
I have two versions of the code for log out
1 )
$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;
2)
session_start();
session_unset();
session_destroy();
Which is the better solution?