#37000 Set SameSite to Lax via a new setcookie() wrapper#12444
#37000 Set SameSite to Lax via a new setcookie() wrapper#12444johnbillion wants to merge 5 commits into
setcookie() wrapper#12444Conversation
… using the array signature for options.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The default value for
SameSitein Chromium-based browsers has been set toLaxsince 2020. This breaks some less-common use cases such as iframing the site, but just as importantly, results in inconsistency across browsers because neither Firefox nor Safari do the same.Since the minimum supported version of PHP is now > 7.3 we can switch to using the array signature for
setcookie()options and specify a value for theSameSiteflag.In order to standardise setting
SameSitetoLaxin all browsers, facilitate being able to change theSameSitevalue (either to tighten it toStrictor loosen it toNone), and to make everything more testable, this PR makes the following changes:wp_set_cookie()wrapper function with filters for controlling the cookie options and whether cookies are sent. This increases the testability of functions that set cookies.wp_unset_cookie()function as a convenience wrapper for unsetting cookies.samesiteoption toLax. I have not identified any cookie that's set by WordPress that would benefit from aSameSitevalue ofStrict, and none that need downgrading toNone.Supporting info
Drupal, Symfony, Laravel, Django, RoR, ASP.NET, Magento, and many other frameworks default to explicitly setting
SameSitetoLaxrather than relying on an implied default in browsers.Trac ticket: https://core.trac.wordpress.org/ticket/37000