ID: 25221 Updated by: [EMAIL PROTECTED] Reported By: henrysim78 at yahoo dot com Status: Bogus Bug Type: *General Issues Operating System: Win2000 PHP Version: 4.3.2 New Comment:
You set 3 cookies with that script..(one without value, 'register') Previous Comments: ------------------------------------------------------------------------ [2003-08-24 09:00:48] henrysim78 at yahoo dot com Thanks, it did work now. But a question keep remain, why PHP seem recognize those COOKIEs still exist? Setcookie("register") do eliminate all of the "Register" array inside the COOKIE, as when i checked with print_r ($_COOKIE) it give result : Array ( [PHPSESSID] => f0cf5ed37c49006512def3576cfb7171 [register] => ) It means [register][one], [register][two] are no longer exist so the "isset" function suppose to return "FALSE"? ------------------------------------------------------------------------ [2003-08-24 08:32:26] [EMAIL PROTECTED] Cookies are set with the name you set them to. You also need to delete them with the name(s) you set them to. Thus deleting these cookies: setcookie("register[one]"); setcookie("register[two]"); RTFM: "You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name" ------------------------------------------------------------------------ [2003-08-24 05:26:29] henrysim78 at yahoo dot com Description: ------------ I'm using PHP Ver.4.3.2 I have the same problem too, when use setcookie(<cookiename>), Cookie is set to %00 instead of erased. The problem happen when it hit this syntax : if(isset($_COOKIE['register'])) {echo $_COOKIE['register'];} Neither isset or !empty function could detect whether it's empty or not. It always return true, so it will try to display the value $_COOKIE['register'] that has been deleted. It returned error message : Notice: Uninitialized string offset: 0 in D:\My Web\register.php on line 186 Thanks in advance. Reproduce code: --------------- setcookie("register[one]","Bill"); //Set the cookie setcookie("register[two]","Jim"); setcookie("register") //Delete the cookie if(isset($_COOKIE['register']['one'])) {echo $_COOKIE['register']['one']; } else {echo "COOKIE Not Exist"; } Expected result: ---------------- It should display "COOKIE Not Exist" as the cookie has been deleted. Actual result: -------------- It try to display the value of deleted COOKIE. It generated error : Notice: Uninitialized string offset: 0 in D:\My Web\register.php on line 186 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25221&edit=1