Skip to content

docs: add warning on CSRF cookie and redirect() #8166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion user_guide_src/source/libraries/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ Token Regeneration
------------------

Tokens may be either regenerated on every submission (default) or
kept the same throughout the life of the CSRF cookie. The default
kept the same throughout the life of the Session or CSRF cookie.

The default
regeneration of tokens provides stricter security, but may result
in usability concerns as other tokens become invalid (back/forward
navigation, multiple tabs/windows, asynchronous actions, etc). You
Expand All @@ -110,6 +112,10 @@ may alter this behavior by editing the following config parameter value in

.. literalinclude:: security/004.php

.. warning:: If you use Cookie based CSRF protection, and :php:func:`redirect()`
after the submission, you must call ``withCookie()`` to send the regenerated
CSRF cookie. See :ref:`response-redirect` for details.

.. note:: Since v4.2.3, you can regenerate CSRF token manually with the
``Security::generateHash()`` method.

Expand Down