I'm running PHP 4.0.6, and I have a problem using session_start() and the Header() functions at the same time.
The situation is that I have a script that creates an inline PDF document using Header statements. It doesn't have to be PDF, it can be anything created with "Header content-type" information.
The problem I have is that I need to validate the user executing the script before the Header() code is executed. If the user has been authenticated, then a session variable has already been set after they log in to the application.
So, here's the problem, when I do a session_start() at the top of the script (to make the session variable available), the Header() functions don't work then because (I think) the session_start() screws up the headers, resulting in a "headers already sent" type of condition.
I wonder if anybody has ran into this, and if a PHP upgrade will fix it, or a work around exists. Thanks. The code looks something like this:
<?
session_start();
if($HTTP_SESSION_VARS=['validated']) {
continue;
}
else {
echo "you're a fool for tryin";
}
Header("Content-type: application/pdf");
Header("Content-Disposition: inline; filename=\"test.pdf\"");
?>
?>