#28409 [Opn->Fbk]: setcookie doesn't seem to work
| From: | iliaa@php.net | Date: | Sat, 15 May 2004 17:29:01 +0000 |
| Subject: | #28409 [Opn->Fbk]: setcookie doesn't seem to work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59658@lists.php.net to get a copy of this message | ||
ID: 28409
Updated by: iliaa@php.net
Reported By: harshit at oinka dot com
-Status: Open
+Status: Feedback
Bug Type: *General Issues
Operating System: Windows 2000 Professional
PHP Version: 4.3.5
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Also, please indicate what php sapi & webserver are you
using.
Previous Comments:
------------------------------------------------------------------------
[2004-05-15 13:50:49] harshit at oinka dot com
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 this bug report at http://bugs.php.net/?id=28409&edit=1