please help me understand this code for logging out
Posted: Sat Feb 11, 2012 5:19 pm
Someone gave me this script for logging out the user and redirect to another page:
I'm not sure about the purpose of ob_start() and ob_flush().
Also, why $_SESSION = array()?
Thanks.
Code: Select all
<?php
ob_start();
$_SESSION = array();
// invalidate session cookie
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-86400, '/');
}
// end session then redirect
session_destroy();
header('Location: /index.php');
ob_flush();
exit;
?>Also, why $_SESSION = array()?
Thanks.