php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #45887 setcookie function set value as 'deleted'
Submitted: 2008-08-22 01:17 UTC Modified: 2008-11-05 09:54 UTC
From: loganathan dot rs at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
 [2008-08-22 01:17 UTC] loganathan dot rs at gmail dot com
Description:
------------
setcookie funciton set value as 'deleted'

setcookie( 'delete_me', '', time() - 1000, '/', '', '' );

The setcookie function will silently change the '' cookie value to 'deleted' and override your expiry time to time() - 1 year.

I only noticed this when the computer I was testing on had it's date set incorrectly to the > 1 year in the past.  The computer connects to the server which has it's date correctly set and thus the cookie on the client doesn't delete but stores the value "deleted" instead.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-22 06:42 UTC] jani@php.net
Note from the code explaining the reason:

/*
* MSIE doesn't delete a cookie when you set it to a null value
* so in order to force cookies to be deleted, even on MSIE, we
* pick an expiry date 1 year and 1 second in the past
*/

And this has been like this since PHP 4..if not even PHP 3.
Might be better to document it finally -> reclassified as docu problem.
 [2008-11-05 09:54 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"This is internally achieved by setting value to 'deleted' and expiration time to one year in past."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 08:01:33 2025 UTC