From: harshit at oinka dot com
Operating system: Windows 2000 Professional
PHP version: 4.3.5
PHP Bug Type: *General Issues
Bug description: setcookie doesn't seem to work
Description:
------------
The setcookie function call as expected was supposed to set a desired
cookie. However due to the presence of a header function immediately after
the setcookie call, the setcookie function fails to set the cookie. I was
using the header function as a means of redirection. I managed to solve
the problrm using a meta refresh but am intrifued as to why setcookie
failed to perform its role. I've checked the return value for setcookie,
it returns a "true" value.
Reproduce code:
---------------
if(empty($_COOKIE['id']){
//set cookie for 24 hours
setcookie("id",123,time()+60*60*24);
header("Location: redirpage.php");
}else{
header("Location: mainpage.php");
}
Expected result:
----------------
After checking for the cookie and setting it the code should redirect to
redirpage.php. It redirects alright, but does not set the cookie.
--
Edit bug report at http://bugs.php.net/?id=28409&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28409&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28409&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28409&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28409&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28409&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28409&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28409&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28409&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28409&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28409&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28409&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28409&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28409&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28409&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28409&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28409&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28409&r=float