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

CookieBanner::getCookie returns NULL even if cookie is readable via $_COOKIE #20

Open
mayfinn opened this issue Apr 6, 2024 · 1 comment

Comments

@mayfinn
Copy link

mayfinn commented Apr 6, 2024

I have a problem reading the cookie via your provided functions. I identified the root problem to be the hashing of cookies in Kirby. The CookieBanner::getCookie returns null because Cookie::get returns null.
This is due to the early access in https://github.com/getkirby/kirby/blob/6b7ac66c55ecac20d6b580ef01a667d1806d5c72/src/Http/Cookie.php#L143

anselmh added a commit to anselmh/kirby-cookie-banner that referenced this issue May 13, 2024
This fixes michnhokn#20.
This also should fix michnhokn#19.

The [`str_contains` function works vice-versa](https://www.php.net/manual/en/function.str-contains.php) than implemented before. In a local test environment this fixed the issues above and worked fine again.
@anselmh
Copy link

anselmh commented May 13, 2024

For completeness, here’s a local workaround for those who need it:

private static function getCookie(): ?string
    {
        $cookie = $_COOKIE[self::COOKIE_NAME] ?? null;

        if (!is_string($cookie) or empty($cookie)) {
            return null;
        }
        return $cookie;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants