#18708 [Bgs]: Header("Location:") doesn't work after setCookie()?

From: Date: Fri, 02 Aug 2002 15:56:59 +0000
Subject: #18708 [Bgs]: Header("Location:") doesn't work after setCookie()?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15847@lists.php.net to get a copy of this message
ID: 18708 User updated by: andywright28@hotmail.com Reported By: andywright28@hotmail.com Status: Bogus Bug Type: HTTP related Operating System: Win2000 sp6a PHP Version: 4.2.2 New Comment: Does Header() not use echo() to print text out? Essentially doing the same thing (with a few checks)? I'm just guessing, as I haven't looked at the source. It just seems strange not to work on a server like IIS. I ran the code originally on Linux/Apache (Mandrake 8.0) and it all worked fine out of the box, using the same machine/browser (Win2k/IE5.5) to browse the web site. And thanks on the info for the Location: header. I think the guys doing <a href="www.phpnuke.net">PHPNuke</a> should take note since its their code I'm quoting from! Previous Comments: ------------------------------------------------------------------------ [2002-08-02 11:33:28] hholzgra@php.net this is not a PHP issue, it is either the webserver or the browser that ignores the SetCookie header on HTTP redirects btw: your Location: header usage is dangerous, the RFC clearly says that you have to use *absolute* URLs in Location: headers ------------------------------------------------------------------------ [2002-08-02 10:57:38] andywright28@hotmail.com <? //some processing $info = base64encode("$information"); setcookie("user",$info,time()+15552000); Header("Location: file.php"); ?> The cookie doesn't get set if a Header() function is used straight after it. If I comment out the header function then the cookie is set ok. I can also replace the Header() function with an echo() as in: echo "<meta http-equiv='refresh' content='0;file.php'>"; and this works fine also. The PHP installed is the 4.2.2 precompiled binary for Windows, running php.exe from IIS version 5. The piece of code is actually used in PHPNuke. Line 502 of /modules/Your_Account/index.php. Am I missing something? Andy ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18708&edit=1

« previous php.bugs (#15847) next »