ID:               1111
 Comment by:       sergio at sergiomoura dot cjb dot net
 Reported By:      cary at active-ideas dot com dot au
 Status:           Closed
 Bug Type:         Misbehaving function
 Operating System: Irix 6.5.2
 PHP Version:      3.0.6
 New Comment:

Ok. I've tested many ways trying to set a cookie to IE with PHP. I know
a lot of ways that you can use to FAIL trying to send a cookie to IE.
But now, does anybody know how can I set a cookie to IE?

Thanx!


Previous Comments:
------------------------------------------------------------------------

[1999-02-02 09:46:10] rasmus

You are making it sound as if IE never sets a cookie if the
Content-Type header is sent last.  That is simply not true.  Point your
browser at www.lerdorf.on.ca/c.php3 for example and then go to
www.lerdorf.on.ca/info.php3.  You will see that two cookies were set; 
test[0] and test[1].  And if you telnet to the server (use a Host
header) you will see that the content-type line is sent last.

The order of the headers is not specified by PHP in the Apache module
version.  All PHP does is fill in a table of headers.  Apache decides
which order they should be sent in.  And as per the HTTP spec, the
order is supposed to be irrelevant.

------------------------------------------------------------------------

[1999-02-02 01:15:15] cary at active-ideas dot com dot au

We are using PHP as a standalone cgi bin program running various
versions of Apache. Even with PHP 3.06 and Apache 1.3.3 this problem
still exists.

It appears that Internet Explorer requires the Set-Cookie header tag to
be AFTER the Content-Type line in the header returned by PHP.

When using the setcookie function it has performed correctly when using
the Netscape browsers. Whereas some websites I noticed were correctly
setting a cookie in IE3 and IE4. On doing a comparison of the headers
returned (by telnetting to port 80 and requesting the output of the PHP
program with a setcookie function) it was apparent that the Set-Cookie
Header tag was being output before the Content-type tag. For the web
sites that were able to succesfully set a cookie in an Explorer site,
they always send the Set-Cookie tag after the Content-Type tag. 

On looking through PHP's source code, it appears that any Content-Type
commands are always output last. That is they are queued as the last
thing to be output. This is causing the PHP setcookie function to fail
when Internet Explorer browsers are being used.

We tried to overcome this by using the Header function to output a
Content-Type tag before the setcookie function was called. But this was
not output immediately and queued for the end when the entire header is
flushed out. If this was possible to output the Content-Type header
tag, then it should solve the problem. Alternatively, the order of the
header tags needs to be re-arranged so that they are output correctly
for IE to understand.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=1111&edit=1

Reply via email to