core-bundle/src/Security/Authentication/Token/TokenChecker.php
public function getFrontendUsername(): ?string
    {
        $token = $this->getToken(FrontendUser::SECURITY_SESSION_KEY);

        if (null === $token || !$token->getUser() instanceof FrontendUser) {
            return null;
        }

        return $token->getUser()->getUsername();
    }
public function getFrontendUsername(): ?string
    {
        $token = $this->getToken(FrontendUser::SECURITY_SESSION_KEY);

        if (null === $token || !$token->getUser() instanceof FrontendUser) {
            return null;
        }

        return $token->getUser()->getUsername();
    }
Gets the front end username from the session.