Skip to content
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

Deprecate the System::setCookie() method #6386

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions core-bundle/contao/library/Contao/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ public static function urlEncode($strPath)
*/
public static function setCookie($strName, $varValue, $intExpires, $strPath=null, $strDomain=null, $blnSecure=null, $blnHttpOnly=false)
{
trigger_deprecation('contao/core-bundle', '5.3', 'Using "Contao\System::setCookie()" has been deprecated and will no longer work in Contao 6. Use Symfony\'s HttpFoundation and kernel.response events instead.');

if (!$strPath)
{
$strPath = Environment::get('path') ?: '/'; // see #4390
Expand Down Expand Up @@ -590,6 +592,8 @@ public static function setCookie($strName, $varValue, $intExpires, $strPath=null
// HOOK: allow adding custom logic
if (isset($GLOBALS['TL_HOOKS']['setCookie']) && \is_array($GLOBALS['TL_HOOKS']['setCookie']))
{
trigger_deprecation('contao/core-bundle', '5.3', 'Using the "setCookie" hook has been deprecated and will no longer work in Contao 6. Use kernel.response events instead.');

foreach ($GLOBALS['TL_HOOKS']['setCookie'] as $callback)
{
$objCookie = static::importStatic($callback[0])->{$callback[1]}($objCookie);
Expand Down