ID: 15441
Comment by: henrysim78 at yahoo dot com
Reported By: paul dot lists at burney dot ws
Status: Closed
Bug Type: Documentation problem
Operating System: Solaris 7
PHP Version: 4.1.1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-02-08 12:27:17] [EMAIL PROTECTED]
This bug has been fixed in CVS.
------------------------------------------------------------------------
[2002-02-08 10:00:26] paul dot lists at burney dot ws
On the documentation page it says:
"When deleting a cookie you should assure that the
expiration date is in
the past, to trigger the removal mechanism in your
browser."
However, since the first delete cookie example doesn't have
any value for the "expire" argument, it is implied that if
called with only the variable name, PHP will automatically
assure that the expiration date is in the past.
The code you provided works, of course. There is
definately a difference in the way that PHP 4.1.x handles
this than previous versions.
I guess this is now a documentation problem. From the
setcookie documentation, under setcookie() delete examples,
the first listed is:
setcookie ("TestCookie");
Which in PHP 4.1.x just sets the cookie to %00 as the
original bug stated. I suggest removing that example.
Also the function definition should no longer suggest that
setcookie only requires one argument.
------------------------------------------------------------------------
[2002-02-08 00:51:59] [EMAIL PROTECTED]
>From the setcookie page.
"When deleting a cookie you should assure that the expiration date is
in the past, to trigger the removal mechanism in your browser."
Try this
setcookie($username_cookie, '', time()-3600);
-Chris
------------------------------------------------------------------------
[2002-02-08 00:26:56] paul dot lists at burney dot ws
Using PHP 4.1.x, the following code, which is intended to
delete a cookie, instead replaces the value with %00 (ascii
entity null?)
Cookies are set with the following:
setcookie($username_cookie,'username');
setcookie($password_cookie,md5('password'));
Cookies are deleted with the following:
setcookie($username_cookie);
setcookie($password_cookie);
Yes, the $username_cookie and $password_cookie variables
have values.
The above is case (a) in the documentation, the simplest
case.
I've tried this on all the systems I have access to.
Affected:
Solaris 7, PHP 4.1.0
Red Hat 7.1, PHP 4.1.1
Not Affected:
Red Hat 7.1, PHP 4.04pl1
Mac OS X 10.1.2, PHP 4.0.6
Solaris 7, PHP 4.06
One affected system that I've used is on a web host
(communitech.net, who just very recently moved to PHP 4.1.0
from 3.0.9, Solaris 7). The other is on the freshly setup
intranet server at my employer (Linux 4.1.1).
Here's the configuration line (Solaris 7, PHP 4.1.0):
�'./configure' '--with-mysql=/usr/local/mysql' '--with-
curl=/root/src/curl/curl-7.9.3' '--with-xml' '--with-
apache=/root/src/apache/apache-fp_1.3.3'
And the one from Red Hat 7, PHP 4.1.1:
'./configure' '--prefix=/usr/local' '--with-apache=/usr/
local/src/apache/Apachetoolbox-1.5.50/apache_1.3.22' '--
enable-exif' '--enable-track-vars' '--with-calendar=shared'
'--enable-safe-mode' '--enable-magic-quotes' '--enable-
trans-sid' '--enable-wddx' '--enable-ftp' '--with-gd=/usr/
local' '--with-zlib' '--enable-gd-native-tt' '--with-t1lib=
/usr/local' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '-
-with-zlib-dir=/usr' '--with-ttf' '--with-freetype-dir=/
usr' '--with-imap=/usr/local' '--with-openssl=/usr' '--
with-mysql=/usr/local/mysql' '--with-pgsql' '--with-ldap'
The same code works in previous versions of PHP to 4.1, as
indicated above. I've tried the code in three different
browsers so I don't think it is browser dependent.
The actual piece of code is part of a larger system. I can
give you the code or access to one of the servers if
necessary.
Thanks in advance.
Paul Burney
Webmaster
Concord Consortium and UCLA GSE&IS
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15441&edit=1