php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #22239 Misleading Documentation on Deleting Cookies
Submitted: 2003-02-16 03:16 UTC Modified: 2003-02-18 05:32 UTC
From: todd at ubermother dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: todd at ubermother dot net
New email:
PHP Version: OS:

 

 [2003-02-16 03:16 UTC] todd at ubermother dot net
In the current version of the PHP html documentation, under the function "setcookie(...)" it states:

If only the name argument is present, the cookie by that name will be deleted from the remote client.

This is only partially true, as the other arguments to the function must be called exactly as they were upon creation of the cookie.  At least this is true for Mozilla 1.1 (verified with the cookie manager), and your documentation seems to indicate the same, when it states under "Common Pitfalls":

Cookies must be deleted with the same parameters as they were set with.

Making this point clear from the beginning would save confusion for developers.  This is also a problem since sites that mirror the documentation (at least zend.org) don't always include the "Common Pitfalls" section.

Consider replacing:

If only the name argument is present, the cookie by that name will be deleted from the remote client.

With:

If the value argument is an empty string (""), and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote browser.

Also, a sample of doing this would be nice:

If in login.php you have:
<?
setcookie("UID","SOMEVALUE","/subdir","myhost.com",TRUE);
?>

You should have in logout.php:
<?
setcookie("UID","","/subdir","myhost.com",TRUE);
?>


Thanks for your attention,
Todd Willey

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-18 05:32 UTC] betz@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 14:00:01 2025 UTC