php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14571 setcookie behavoir changed in 4.1 from previous versions
Submitted: 2001-12-17 21:36 UTC Modified: 2001-12-18 04:03 UTC
From: smclean at scoreinfo dot tv Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.1.0 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: smclean at scoreinfo dot tv
New email:
PHP Version: OS:

 

 [2001-12-17 21:36 UTC] smclean at scoreinfo dot tv
The behavoir of the setcookie function changed in 4.1.0 even though no such change was documented in the changelog.  This had the effect of disabling an application of mine until I figured out what happened.

In PHP <4.1.0, the code:

 setcookie("cookiename","");

would delete the cookie 'cookiename'.

In PHP 4.1.0, this function created a cookie with a null value named cookiename.

I know this is a rather silly change, and you wouldn't expect someone to ever specify a blank value in the second argument, but it did cause a short downtime in our website  software.  

I posted this on the setcookie() manual page but it was rejected on grounds that it was more of a bug report than anything, so I thought I'd post it here.

Thanks 

Sean

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-18 03:48 UTC] sander@php.net
This hasn't changed. setcookie('name','') doesn't remove the cookie, and it never did. To remove a cookie, use setcookie with a expire-date in the past, i.e. setcookie('name','', time()-10000).
 [2001-12-18 04:03 UTC] derick@php.net
From the manual: (http://uk.php.net/manual/en/function.setcookie.php)

 Some examples follow how to send cookies:

Example 1. setcookie() send examples

a. setcookie ("TestCookie", "Test Value");
b. setcookie ("TestCookie", $value,time()+3600);  /* expire in 1 hour */
c. setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);

Examples follow how to delete cookies send in previous example:

Example 2. setcookie() delete examples

a. setcookie ("TestCookie");
// set the expiration date to one hour ago
b. setcookie ("TestCookie", "", time() - 3600);
c. setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1);

When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.
 [2002-02-21 09:06 UTC] alex at PolesApart dot dhs dot org
In 4.1.1 setcookie("cookiename") don't work for me to removing a cookie. It sets a cookie with empty value as if I did setcookie("cookiename", "");

In 4.0.x setcookie("cookiename"); was enough.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 01:01:28 2024 UTC