+
Skip to content

Conversation

dragosgd
Copy link
Contributor

Purpose

Fix cookie consent banner reappearing after users make their choice. The banner was showing up again on subsequent page visits even after users clicked "Allow" or "Decline", causing a poor user experience.

Changes

Critical Bug Fixes:

  • Fixed consentDenied() function which was incorrectly storing true instead of false when users declined cookies
  • Replaced faulty consent checking logic that treated both granted and denied consent the same way

Improved Cookie Handling:

  • Enhanced storeChoice() to set proper cookie attributes (1-year expiration, path scope, SameSite security)
  • Updated loadChoice() to return null for no stored choice, distinguishing it from boolean consent values

Enhanced Logic Flow:

  • Implemented three-way consent checking:

    • stored === true: Enable tracking and hide banner
    • stored === false: Hide banner without enabling tracking
    • stored === null: Show banner for first-time users

Safety Improvements:

  • Added null checks before removing DOM elements to prevent JavaScript errors
  • Only call Matomo's rememberCookieConsentGiven when consent was actually granted

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

CLA acceptance

By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0

@dragosgd dragosgd self-assigned this Sep 17, 2025
@dragosgd dragosgd added the preview Trigger a documentation preview for a PR. label Sep 17, 2025
Copy link

github-actions bot commented Sep 17, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://developer.concordium.software/pr-preview/pr-1423/

Built to branch gh-pages at 2025-09-17 08:46 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@dragosgd dragosgd requested a review from DOBEN September 30, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Trigger a documentation preview for a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载