Configure Consent Expiration in the Cookie Banner

Prev Next

This section explains how to configure the consent expiration in your cookie banner so that it automatically reappears after a specific time to request consent again.

In this example, the expiration is set to 6 months.
After this period, the banner will show again to collect updated consent.


Example Implementation

<script>
  // === CONFIGURATION: set consent expiration time ===
  // 6 months = 1000 ms * 60 s * 60 m * 24 h * 30 days * 6 months
  var wait = 15552000000; // milliseconds for six months
  
  function reopenWidget() {
    if (!window.bigidcmp) return;
    
    var consent = window.bigidcmp.getConsent();
    if (consent.updatedAt < (Date.now() - wait)) {
      window.bigidcmp.deleteConsent();
      window.bigidcmp.showWidget();
    }
  }
  
  if (window.bigidcmp && window.bigidcmp.getConsent && window.bigidcmp.showWidget) {
    reopenWidget();
  } else {
    window.addEventListener('bigidcmp:widget_ready', reopenWidget);
  }
</script>

How to Change the Expiration Period

You can easily customize how long consent remains valid by modifying the wait value.
This variable defines the duration in milliseconds before the banner reappears.

Duration

Formula Example

wait Value

1 week (default example)

1000 * 60 * 60 * 24 * 7

604800000

6 months (current example)

1000 * 60 * 60 * 24 * 30 * 6

15552000000

12 months (1 year)

1000 * 60 * 60 * 24 * 30 * 12

31104000000


Result

Once the defined expiration period passes, the stored consent is considered expired.
When users return to your website after that time, the cookie banner will automatically reappear to request their consent again.