diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
index 95888f948337d55a8cc298bb29f420527b9d45ef..cf5bc3e208c1995eda0199f910f8337411efca4e 100644
--- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
+++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
@@ -1810,18 +1810,12 @@ class BackendUserAuthentication extends AbstractUserAuthentication
     }
 
     /**
-     * Getter for the cookie name
-     *
-     * @static
-     * @return string returns the configured cookie name
+     * Returns the configured cookie name
      */
-    public static function getCookieName()
+    public static function getCookieName(): string
     {
-        $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
-        if (empty($configuredCookieName)) {
-            $configuredCookieName = 'be_typo_user';
-        }
-        return $configuredCookieName;
+        $configuredCookieName = trim((string)($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName'] ?? ''));
+        return $configuredCookieName !== '' ? $configuredCookieName : 'be_typo_user';
     }
 
     /**
diff --git a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
index fb4714717ad53b420fd426fca90acdd35fb59ce6..32ff2af66c1216ee32feef073de74b85f687e03a 100644
--- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
+++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
@@ -163,16 +163,11 @@ class FrontendUserAuthentication extends AbstractUserAuthentication
 
     /**
      * Returns the configured cookie name
-     *
-     * @return string
      */
-    public static function getCookieName()
+    public static function getCookieName(): string
     {
-        $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cookieName']);
-        if (empty($configuredCookieName)) {
-            $configuredCookieName = 'fe_typo_user';
-        }
-        return $configuredCookieName;
+        $configuredCookieName = trim((string)($GLOBALS['TYPO3_CONF_VARS']['FE']['cookieName'] ?? ''));
+        return $configuredCookieName !== '' ? $configuredCookieName : 'fe_typo_user';
     }
 
     /**