1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 07:42:10 +01:00

Fix setcookie() documentation for invalid options in PHP 8.0+ (#5104)

And move it to the usual dedicated Errors/Exception section

Co-authored-by: Gina Peter Banyard <girgias@php.net>
This commit is contained in:
Louis-Arnaud
2026-01-30 11:06:50 +01:00
committed by GitHub
parent 8108ac2a62
commit b41e78e623

View File

@@ -158,8 +158,9 @@
An associative <type>array</type> which may have any of the keys
<literal>expires</literal>, <literal>path</literal>, <literal>domain</literal>,
<literal>secure</literal>, <literal>httponly</literal> and <literal>samesite</literal>.
If any other key is present an error of level <constant>E_WARNING</constant>
is generated. The values have the same meaning as described for the
</simpara>
<simpara>
The values have the same meaning as described for the
parameters with the same name. The value of the <literal>samesite</literal>
element should be either <literal>None</literal>, <literal>Lax</literal>
or <literal>Strict</literal>.
@@ -168,6 +169,7 @@
<literal>samesite</literal> element is omitted, no SameSite cookie
attribute is set.
</simpara>
<note>
<simpara>
To set a cookie that includes attributes that aren't among the keys listed,
@@ -197,6 +199,25 @@
</simpara>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<simpara>
If the <parameter>options</parameter> array contains unsupported keys:
</simpara>
<itemizedlist>
<listitem>
<simpara>
Prior to PHP 8.0.0, an <constant>E_WARNING</constant> was generated.
</simpara>
</listitem>
<listitem>
<simpara>
As of PHP 8.0.0, a <exceptionname>ValueError</exceptionname> is thrown.
</simpara>
</listitem>
</itemizedlist>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
@@ -223,6 +244,14 @@
SameSite cookie attribute.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Passing unsupported keys now throws a <exceptionname>ValueError</exceptionname>
instead of emitting an <constant>E_WARNING</constant>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>