php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20025 header() not working correctly after session_start()
Submitted: 2002-10-22 09:19 UTC Modified: 2002-10-22 10:46 UTC
From: jaco at premsoft dot co dot za Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.0-pre1 OS: FreeBSD 4.7, Windows 2000
Private report: No CVE-ID: None
 [2002-10-22 09:19 UTC] jaco at premsoft dot co dot za
Hi all.

[description]
I experience a problem that the header() function does not work correctly after session_start is called. What I am trying to achive is to download a file, using header().
[/description]

[code]
The following code works:

<?php
   $dlfile = "./temp.zip";
   header("Content-Type: application/download-script-by-hex\n");
   header("Content-Disposition: attachment; filename=\"$dlfile\"");
   header("Content-Transfer-Encoding: binary");
?>


The following code fails:

<?php
   session_start();
   $dlfile = "./temp.zip";
   header("Content-Type: application/download-script-by-hex\n");
   header("Content-Disposition: attachment; filename=\"$dlfile\"");
   header("Content-Transfer-Encoding: binary");
?>

[/code]

[errors]
I also set the value of session.track_sid to 0, (as advised in Bug #19991), with no luck.

When I access this page with IE 6.00.2600.0000, running on Windows 2000, it givies `Internet Explorer is unable to open this Internet site'.

When I use Lynx, running on FreeBSD 4.7, I can download the file, but I receive a 4 byte ascii file, containing nothing but spaces.

The file I am trying to download is a 387 byte zipped file.
[/errors]

[setup]
The PHP installation runs on FreeBSD 4.7, together with Apache 1.3.27.

[PHP Configure options]
./configure --with-openssl --with-mysql=/usr/local/mysql --with-trans-sid --enable-sockets --with-apxs=/usr/local/apache/bin/apxs

Please note that I have tried this setup with both PHP 4.2.3 and PHP 4.3.0-Pre1, both with setting session.trans_sid=1 and session.trans_sid=0 set in the config file.
[/PHP Configure options]
[setup]

Regards
Jaco van Tonder

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-22 10:35 UTC] sniper@php.net
This is not PHP bug but a bug in IE 6.
(I just fought 2 hours with this very same problem this morning..:)

The fix was to either change 'session.cache_limiter = public' in php.ini or do same using session_cache_limiter('public'); before session_start();
in the script.

And those headers you're sending are not really correct either..check the manual page for header() function
and the user comments there..


If you're using SSL then this might also be needed:
                                http://www.extremetech.com/article/0,3396,s=201&a=24899,00.asp

and:
                                http://www.modssl.org/docs/2.8/ssl_faq.html#ToC49


 [2002-10-22 10:46 UTC] hholzgra@php.net
oh, yes ...

IE's are not cacheing stuff that comes with
nocache headers, which the session extension
adds by default 

thats ok as long as IE can display the content
right away, but if it is going to pass it to
a plugin or trying to download and save it it
passes on the name of a nonexistant local cache
file ...

for the lynx case: do you actualy have a readfile($dlfile)
call or something like that in your code or is it really
like in your examples?

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 01 20:00:02 2025 UTC