#24855 [Opn->Fbk]: setcookie() doesn't work with header() function

From: Date: Tue, 29 Jul 2003 15:54:02 +0000
Subject: #24855 [Opn->Fbk]: setcookie() doesn't work with header() function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-45000@lists.php.net to get a copy of this message
ID: 24855 Updated by: sniper@php.net Reported By: tomasz at biznespolska dot pl -Status: Open +Status: Feedback Bug Type: IIS related Operating System: Windows NT 4.0 PHP Version: 4.3.2 New Comment: Try this with Apache 1.3.28. And redirecting with 'Location:' needs full URL, not just the filename. e.g. header("Location: http://www.php.net/index.php"); Previous Comments: ------------------------------------------------------------------------ [2003-07-29 10:17:10] tomasz at biznespolska dot pl Description: ------------ I'm using Windows NT4 with IIS4.0. I have found that function setcookie() doesn't work (doesn't send cookie) , when header() function is called, somewhere after. When I comment line with header() then it sends cookie to browser, but I'm not able to redirect user to another page. I know, I can use <meta http-equiv="refresh" content="0; url=index.php"> but this is not best soultion. System Windows NT WWW 4.0 build 1381 Build Date May 28 2003 15:06:05 Server API CGI/FastCGI Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINNT40\php.ini PHP API 20020918 PHP Extension 20020429 Zend Extension 20021010 Debug Build no Thread Safety enabled Registered PHP Streams php, http, ftp, compress.zlib Reproduce code: --------------- setcookie('BPKEY', "blah=blah", time()+$_CFG['cookie_lifetime'], '/', 'biznespolska.pl'); header( 'Location: index.php' ); Expected result: ---------------- It should set cookie named BPKEY, and redirect to page index.php Actual result: -------------- Only redirects to page index.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24855&edit=1

« previous php.bugs (#45000) next »