whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
312 stars 37 forks source link

Accepting cookies doesn't save the choice #10

Closed danielveselinov closed 1 year ago

danielveselinov commented 1 year ago

Hey,

I followed the documentation and configured everything but whenever I click 'Accept all' , or the other choices for the cookies it returns something like:

scripts:  ["<script async src="https://www.googletagmanager.com/gtag/js?id=test"></script>",…]
status:  "ok"

but later whenever I refresh the page, or just open another link from the menu it pops again the modal.

Anything where I may be wrong?

toonvandenbos commented 1 year ago

Hi @danielveselinov,

Can you check if the consent cookie has been set after accepting via the cookie modal? And could you show the content of that cookie here? Thanks!

danielveselinov commented 1 year ago

Hi @toonvandenbos

After click 'Accept all' image

Application tab -> Cookies image

toonvandenbos commented 1 year ago

Hmmmm, that is weird, the consent cookie doesn't seem to be set. Could you check the "Set-Cookie" header in the HTTP response and post the result here?

Also, did you change anything to the package's config file? Domain or cookie name maybe?

danielveselinov commented 1 year ago

This is what I have exactly in the config file:

 'url' => [
        'domain' => env('APP_URL'),
        'prefix' => 'cookie-consent',
    ],
'cookie' => [
        'name' => Str::slug(env('APP_NAME', 'laravel'), '_') . '_cookie_consent',
        'duration' => (60 * 24 * 365),
        'domain' => env('APP_URL'),
    ],
    'google_analytics_id' => env('GOOGLE_ANALYTICS_ID', ''),
'policy' => null,

And here is the result from the header 'Set-Cookie' Set-Cookie: continental_dispatch_academy_stage_cookie_consent=%7B%22consent_at%22%3A1689583649%2C%22continental_dispatch_academy_stage_cookie_consent%22%3Atrue%2C%22continental_dispatch_academy_stage_session%22%3Atrue%2C%22XSRF-TOKEN%22%3Atrue%2C%22_ga%22%3Atrue%2C%22_ga_TEST%22%3Atrue%2C%22_gid%22%3Atrue%2C%22_gat%22%3Atrue%7D; expires=Tue, 16 Jul 2024 08:47:29 GMT; Max-Age=31536000; path=/; domain=https://draft.continentaldispatchacademy.mk; secure; httponly; samesite=lax

image

Also I notice this warning, but what does it exactly means?

danielveselinov commented 1 year ago

Hi @toonvandenbos , anything?

ceejayoz commented 1 year ago

@danielveselinov Your domain value should be draft.continentaldispatchacademy.mk. No https:// at the start; that makes it a URL, not a domain.

jornatf commented 10 months ago

Hi,

I have a similar problem, except the consent cookie is saved in Chrome but not in Safari. However, in Safari the option to block cookies is disabled.

I don't understand.