if(!isset($_SESSION['user'])) { ob_start(); header("Location: https://sitename.com/login.php"); exit(); } else { // my further code }