Login code and if successful, a header redirect is implemented. It works at random times, I don't know what I'm doing to get it working and then for it to fail.
<?php
ob_start();
require ("include/PassHash.php");
if(isset($_POST['login'])){
// Returns more than 0 rows (Email found)
if($total>0 && PassHash::check_password($row['password'], $_POST['password'])){
// Correct credentials.
$_SESSION['user_id'] = $row['id'];
$_SESSION['user_email'] = $email;
session_set_cookie_params(24*60*60);
header("Location: /index.php?p=user_account");
exit();
ob_end_flush();
} else {
// Incorrect password / email.
}
}
?>