diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
index c1512caa39c5cd51c00a54104c52926f963770fe..f0c2868cfd68a07d8c888aee3b26426c7b86098d 100644
--- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
+++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
@@ -2044,18 +2044,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 983e4626a58a029dc170e7a9799cd4ba8631fb58..c03f45c572d8052f5a03118e2132b44564f51d2a 100644
--- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
+++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php
@@ -191,16 +191,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';
     }
 
     /**