diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index 2b6fc7299231..d8dbf5c4294f 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -57,6 +57,8 @@ Interface Changes or implemented these interfaces, all these changes are backward compatible and require no intervention. +- **ResponseInterface:** The default value of the third parameter ``$expire`` of + the ``ResponseInterface::setCookie()`` has been fixed from ``''`` to ``0``. - **Logger:** The `psr/log `_ package has been upgraded to v2.0.0. @@ -65,6 +67,15 @@ Interface Changes Method Signature Changes ======================== +Setting Cookies +--------------- + +The third parameter ``$expire`` in :php:func:`set_cookie()` and +:php:meth:`CodeIgniter\\HTTP\\Response::setCookie()` has been fixed. + +The type has been changed from ``string`` to ``int``, and the default value has +been changed from ``''`` to ``0``. + FileLocatorInterface -------------------- diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst index 10002e2a9eb5..296f1a3dd471 100755 --- a/user_guide_src/source/helpers/cookie_helper.rst +++ b/user_guide_src/source/helpers/cookie_helper.rst @@ -21,7 +21,7 @@ Available Functions The following functions are available: -.. php:function:: set_cookie($name[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = false[, $httpOnly = false[, $sameSite = '']]]]]]]]) +.. php:function:: set_cookie($name[, $value = ''[, $expire = 0[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = false[, $httpOnly = false[, $sameSite = '']]]]]]]]) :param array|Cookie|string $name: Cookie name *or* associative array of all of the parameters available to this function *or* an instance of ``CodeIgniter\Cookie\Cookie`` :param string $value: Cookie value diff --git a/user_guide_src/source/outgoing/response.rst b/user_guide_src/source/outgoing/response.rst index 078d9d11042a..8d9acb39d126 100644 --- a/user_guide_src/source/outgoing/response.rst +++ b/user_guide_src/source/outgoing/response.rst @@ -453,7 +453,7 @@ The methods provided by the parent class that are available are: followed by the response body. For the main application response, you do not need to call this as it is handled automatically by CodeIgniter. - .. php:method:: setCookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = false[, $httponly = false[, $samesite = null]]]]]]]]) + .. php:method:: setCookie($name = ''[, $value = ''[, $expire = 0[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = false[, $httponly = false[, $samesite = null]]]]]]]]) :param array|Cookie|string $name: Cookie name *or* associative array of all of the parameters available to this method *or* an instance of ``CodeIgniter\Cookie\Cookie`` :param string $value: Cookie value @@ -481,7 +481,7 @@ The methods provided by the parent class that are available are: .. literalinclude:: response/023.php Only the ``name`` and ``value`` are required. To delete a cookie set it with the - ``expire`` blank. + ``value`` blank. The ``expire`` is set in **seconds**, which will be added to the current time. Do not include the time, but rather only the number of seconds diff --git a/user_guide_src/source/outgoing/response/023.php b/user_guide_src/source/outgoing/response/023.php index 3d0855739e96..dd3d905add0e 100644 --- a/user_guide_src/source/outgoing/response/023.php +++ b/user_guide_src/source/outgoing/response/023.php @@ -3,7 +3,7 @@ $cookie = [ 'name' => 'The Cookie Name', 'value' => 'The Value', - 'expire' => '86500', + 'expire' => 86500, 'domain' => '.some-domain.com', 'path' => '/', 'prefix' => 'myprefix_',