Files
dotter_t3/packages/watten/Classes/Utilities/CookieUtility.php
T
2026-10-18 17:49:22 +02:00

56 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace HermannTelser\Watten\Utilities;
/***
*
* This file is part of the "mindshape Cookie Consent" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Daniel Dorndorf <dorndorf@mindshape.de>, mindshape GmbH
*
***/
/**
* @package HermannTelser\Watten\Utility
*/
class CookieUtility
{
public const DEFAULT_COOKIE_NAME = 'watten';
/**
* @param string $name
* @return array|null
*/
public static function getCookieValue(string $name = self::DEFAULT_COOKIE_NAME): ?array
{
if (false === self::hasCookie($name)) {
return null;
}
return json_decode($_COOKIE[$name], true);
}
/**
* @param string $named
* @return bool
*/
public static function hasCookie(string $name = self::DEFAULT_COOKIE_NAME): bool
{
return true === array_key_exists($name, $_COOKIE);
}
/**
* @param string $name
*/
public static function deleteCookie(string $name = self::DEFAULT_COOKIE_NAME): void
{
unset($_COOKIE[$name]);
}
}