Skip to content

Commit 6ead627

Browse files
committed
docs: add notes and descriptions for setting cookies
1 parent e063cbe commit 6ead627

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

user_guide_src/source/helpers/cookie_helper.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ The following functions are available:
4242
a description of its use, as this function is an alias for
4343
:php:meth:`CodeIgniter\\HTTP\\Response::setCookie()`.
4444

45+
.. note:: This helper function just sets browser cookies to the global response
46+
instance that ``Services::response()`` returns. So, if you create and
47+
return another response instance (e.g., if you call :php:func:`redirect()`),
48+
the cookies set here will not be sent automatically.
49+
4550
.. php:function:: get_cookie($index[, $xssClean = false[, $prefix = '']])
4651
4752
:param string $index: Cookie name
@@ -78,6 +83,9 @@ The following functions are available:
7883
This function is otherwise identical to :php:func:`set_cookie()`, except that it
7984
does not have the ``value`` and ``expire`` parameters.
8085

86+
This also just sets browser cookies for deleting the cookies to the global
87+
response instance that ``Services::response()`` returns.
88+
8189
.. note:: When you use :php:func:`set_cookie()`,
8290
if the ``value`` is set to empty string and the ``expire`` is set to ``0``, the cookie will be deleted.
8391
If the ``value`` is set to non-empty string and the ``expire`` is set to ``0``, the cookie will only last as long as the browser is open.
@@ -95,4 +103,6 @@ The following functions are available:
95103
:param string $prefix: Cookie prefix
96104
:rtype: bool
97105

98-
Checks if a cookie exists by name. This is an alias of ``Response::hasCookie()``.
106+
Checks if a cookie exists by name in the global response instance that
107+
``Services::response()`` returns. This is an alias of
108+
:php:meth:`CodeIgniter\\HTTP\\Response::hasCookie()`.

user_guide_src/source/outgoing/response.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ The methods provided by the parent class that are available are:
384384
.. note:: Prior to v4.2.7, the default values of ``$secure`` and ``$httponly`` were ``false``
385385
due to a bug, and these values from **app/Config/Cookie.php** were never used.
386386

387-
Sets a cookie containing the values you specify. There are two ways to
387+
Sets a cookie containing the values you specify to the Response instance.
388+
389+
There are two ways to
388390
pass information to this method so that a cookie can be set: Array
389391
Method, and Discrete Parameters:
390392

@@ -439,6 +441,8 @@ The methods provided by the parent class that are available are:
439441

440442
Delete an existing cookie.
441443

444+
.. note:: This also just sets browser cookie for deleting the cookie.
445+
442446
Only the ``name`` is required.
443447

444448
The ``prefix`` is only needed if you need to avoid name collisions with

0 commit comments

Comments
 (0)