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

Cookie display incorrect using Varnish #120

Open
sanhofman opened this issue Oct 15, 2023 · 0 comments
Open

Cookie display incorrect using Varnish #120

sanhofman opened this issue Oct 15, 2023 · 0 comments

Comments

@sanhofman
Copy link

Hi,

When using Cookie Consent Bundle with Varnish, the cookie consent is displayed incorrectly.

We experience two issues:

  • The cookie consent is saved in Varnish (consent only shows 1 time per page)
  • Randomly, it appears the consent is shown even after the user has saved his consent

Using like:

{% if chcookieconsent_isCookieConsentSavedByUser() == false %}
	{{ render_esi(path('ch_cookie_consent')) }}
{% endif %}

In Varnish we strip the cookies correctly:

sub vcl_recv {

    set req.http.Surrogate-Capability = "abc=ESI/1.0";

    if (req.http.Cookie) {
        set req.http.Cookie = ";" + req.http.Cookie;
        set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
        set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
        set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
        set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");

        if (req.http.Cookie == "") {
            # If there are no more cookies, remove the header to get page cached.
            unset req.http.Cookie;
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant