#28409 [Com]: setcookie doesn't seem to work
| From: | webmaster at 8interactive dot com | Date: | Sat, 24 Jul 2004 02:29:02 +0000 |
| Subject: | #28409 [Com]: setcookie doesn't seem to work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63448@lists.php.net to get a copy of this message | ||
ID: 28409
Comment by: webmaster at 8interactive dot com
Reported By: harshit at oinka dot com
Status: No Feedback
Bug Type: *General Issues
Operating System: Windows 2000 Professional
PHP Version: 4.3.5
New Comment:
I have the same problem. PHP version 4.3.3 on Windows NT WIN406 5.0.
I got the cookies to set after I got rid of the header line. This
needs to be fixed.
Previous Comments:
------------------------------------------------------------------------
[2004-05-24 01:00:03] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2004-05-15 19:55:53] solace at ezmail dot ru
Very strange, but I can advise:
1) Use full URL with host name in location header
2) Output something to browser (echo "anything") after header().
------------------------------------------------------------------------
[2004-05-15 19:29:00] iliaa@php.net
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.
------------------------------------------------------------------------
[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