php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #6162 setcookie("<cookiename>") doesn't clear the previous set cookie anymore
Submitted: 2000-08-15 07:20 UTC Modified: 2000-08-15 19:50 UTC
From: akoole at wirehub dot net Assigned: sniper (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.0.1pl2 OS: FreeBSD 3.5-STABLE
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: akoole at wirehub dot net
New email:
PHP Version: OS:

 

 [2000-08-15 07:20 UTC] akoole at wirehub dot net
For some reason, and I've not noticed this before,

setcookie("<cookiename>","<somevalue>"); 

works fine,

but after that, if you wish to clear the cookie wich was set with:
setcookie("<cookiename>");

doesn't work anymore, thus leaving the cookie present until it expires (in this case when the browser is closed)

is this a bug or something that is only misbehaving on my system?

Cheers,
Arjan

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-15 07:52 UTC] sniper@php.net
setcookie("test"); 

Deletes the cookie like it should in my system. 
Are you trying to set and delete the cookie in same script?
The order in which this should be done is different in php3 and php4.

--Jani
 [2000-08-15 11:08 UTC] sniper@php.net
Reset type to Documentation Problem. There isn't anything about deleting cookies
in the manual section for setcookie function.

When cookies are set with the optional parameters, those parameters must be
used also when the cookie is deleted.

--Jani
 [2000-08-15 14:36 UTC] waldschrott@php.net
read thoroughly...

taken from setcookie() doc:
[...]
All the arguments except the name argument are optional. If
only the name argument is present, the cookie by that name
will be deleted from the remote client
[...]
 [2000-08-15 14:37 UTC] waldschrott@php.net
reporter, please respond to entry "[2000-08-15 11:08:17]
sniper@php.net"
 [2000-08-15 17:53 UTC] sniper@php.net
Probably my mistake not to inform this bug report that user knows this. 
It was me who analyzed and confirmed that the setcookie() documentation
misses some information about deleting cookies. 

And the function prototype there is wrong too. 
It says that all the parameters are needed..

If cookie is set with one or more of the optional parameters, it has to be 
deleted with the same parameters. 

So this is documentation problem which I (if someone doesn't get to it first) will
fix when I have time.

--Jani


 [2000-08-15 19:50 UTC] sniper@php.net
Documentation fixed in CVS.

--Jani
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of sniper
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=3bc1986d7f6a8c1fa9d0d4492d2d21dac75488eb
Log: Fixed bug #6162.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 09:00:02 2026 UTC