the webapge am playing with at the moment, i do the following to allow redirects in if statements.
ob_start();
at the start of the page
and then later on i might have the following
if ( ($NOF_REQUEST->Session("Logged_In_Real") != "True") ) {
header("location: http://sydsrv02/real_estate_admin.php"); exit;
} else {
rest of page here.
this solved my problem and it sounds just like yours
just ensure that ob_start() is at the start of the page