You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/changelogs/v4.2.1.rst
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,3 +16,4 @@ Behavior Changes
16
16
================
17
17
18
18
- Guessing the file extension from the MIME type has been changed if the proposed extension is not valid. Previously, the guessing will early terminate and return ``null``. Now, if a proposed extension is given and is invalid, the MIME guessing will continue checking using the mapping of extension to MIME types.
19
+
- If there is a cookie with a prefixed name and a cookie with the same name without a prefix, the previous ``get_cookie()`` had the tricky behavior of returning the cookie without the prefix. Now the behavior has been fixed as a bug, and has been changed. See :ref:`Upgrading <upgrade-421-get_cookie>` for details.
:param bool $xssClean: Whether to apply XSS filtering to the returned value
46
+
:param string|null $prefix: Cookie name prefix. If set to ``''``, the default value from **app/Config/Cookie.php** will be used. If set to ``null``, no prefix
46
47
:returns: The cookie value or null if not found
47
48
:rtype: mixed
48
49
50
+
.. note:: Since v4.2.1, the third parameter ``$prefix`` has been introduced and the behavior has been changed a bit due to a bug fix. See :ref:`Upgrading <upgrade-421-get_cookie>` for details.
51
+
49
52
This helper function gives you friendlier syntax to get browser
50
53
cookies. Refer to the :doc:`IncomingRequest Library </incoming/incomingrequest>` for
51
54
detailed description of its use, as this function acts very
52
55
similarly to ``IncomingRequest::getCookie()``, except it will also prepend
53
56
the ``Config\Cookie::$prefix`` that you might've set in your
54
57
**app/Config/Cookie.php** file.
55
58
56
-
.. warning:: Using XSS filtering is a bad practice. It does not prevent XSS attacks perfectly. Using ``esc()`` with the correct ``$context`` in the views is recommended.
59
+
.. warning:: Using XSS filtering is a bad practice. It does not prevent XSS attacks perfectly. Using ``esc()`` with the correct ``$context`` in the views is recommended.
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_421.rst
+35Lines changed: 35 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,41 @@ app/Config/Mimes.php
23
23
Breaking Changes
24
24
****************
25
25
26
+
.. _upgrade-421-get_cookie:
27
+
28
+
get_cookie()
29
+
============
30
+
31
+
If there is a cookie with a prefixed name and a cookie with the same name without a prefix, the previous ``get_cookie()`` had the tricky behavior of returning the cookie without the prefix.
32
+
33
+
For example, when ``Config\Cookie::$prefix`` is ``prefix_``, there are two cookies, ``test`` and ``prefix_test``:
34
+
35
+
.. code-block:: php
36
+
37
+
$_COOKIES = [
38
+
'test' => 'Non CI Cookie',
39
+
'prefix_test' => 'CI Cookie',
40
+
];
41
+
42
+
Previously, ``get_cookie()`` returns the following:
43
+
44
+
.. code-block:: php
45
+
46
+
get_cookie('test'); // returns "Non CI Cookie"
47
+
get_cookie('prefix_test'); // returns "CI Cookie"
48
+
49
+
Now the behavior has been fixed as a bug, and has been changed like the following.
50
+
51
+
.. code-block:: php
52
+
53
+
get_cookie('test'); // returns "CI Cookie"
54
+
get_cookie('prefix_test'); // returns null
55
+
get_cookie('test', false, null); // returns "Non CI Cookie"
56
+
57
+
If you depend on the previous behavior, you need to change your code.
58
+
59
+
.. note:: In the example above, if there is only one cookie ``prefix_test``,
60
+
the previous ``get_cookie('test')`` also returns ``"CI Cookie"``.
0 commit comments