Re: header ('Content-type...') does not work properly if session_start initiated...

From: Date: Fri, 26 Sep 2003 21:00:22 +0000
Subject: Re: header ('Content-type...') does not work properly if session_start initiated...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164071@lists.php.net to get a copy of this message
* Thus wrote Alex Shi (chpshi@eol.ca): > Hello, > > I have a strange problem with a download script. Here is the situation: > On my development server, the php is 4.0.6 while on the application > server it is 4.3.2. I created a very simple code for opening pdf in > browser. the main part of it is like following: > > <? > session_start (); > ... > > $docPath = '/path/to/file_name.pdf'; > $pdftmp_name = 'tmp_name.pdf'; > > header ('Cache-Control: no-store, no-cache, must-revalidate'); > header ('Content-Type: application/pdf'); > header ('Content-disposition: inline; filename=' . $pdftmp_name); > header ('Content-length: ' . filesize ($docPath)); > > readfile ($docPath); > ?> > > This code is working perfect on development server. However > on the application server, it will first ask for confirm downloading > then report error saying that cannot download. > > I checked the code line by line and found that if remove the first > line "session_start ()" then it will work in the correct way. However > session is required for this script. I don't understand why it works > OK on the development server but not for application server. I'm not even sure how session_start() can even do a thing like that. Unless you have a problem with headers already sent, error. There was a discussion on this a few weeks back here, but unfortantly I didn't follow the thread. hmm.. i think i just rememberd that it might had to do with making sure that session.cache_limiter being set as 'nocache'. Search the archives, the answer is there i believe. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#164071) next »