|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-05-15 19:29 UTC] iliaa@php.net
[2004-05-15 19:55 UTC] solace at ezmail dot ru
[2004-05-24 01:00 UTC] php-bugs at lists dot php dot net
[2004-07-24 04:27 UTC] webmaster at 8interactive dot com
[2005-06-16 09:39 UTC] gamarilla at fassgroup dot com dot ar
[2006-04-28 20:49 UTC] apaganini at nassaucountyny dot gov
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
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.