php / php/doc-en

Issue with setcookie with empty string value

Open
#4,614 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Affected page

https://www.php.net/manual/en/function.setcookie.php#:~:text=If%20the%20value%20argument%20is,expiration%20time%20in%20the%20past.

Issue description

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 client. This is internally achieved by setting value to 'deleted' and expiration time in the past.

Steps to reproduce

setcookie( 'abcdef', '', time() + 3600 );
var_dump( headers_list() );

Suggested fix

The bold highlighted part of the doc is wrong, since it will always do that if the cookie value is empty string.

EDIT: it seems the documented behavior was how it worked at least until PHP 5.6, however since some PHP 7 version this changed

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the affected setcookie() page and review the statement about an empty value, especially the highlighted condition. Run the provided PHP snippet if needed to compare the documented behavior with the output. Done means the wording accurately reflects current PHP behavior and the example remains consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.