Describe the bug
The client-side of the plugin sends requests to the POST /wp-json/pressidium-cookie-consent/v1/consent endpoint on every page visit.
This happens because the request logic is currently attached to both the onConsent() and onChange() events, while onConsent() is triggered on every page load after consent has already been given.
As a result, redundant consent requests are sent even when the user’s consent state has not changed.
Steps to reproduce
Detailed steps to reproduce the behavior:
- Visit a site using the plugin
- Accept or reject cookies from the consent modal
- Open the browser’s Network tab
- Navigate to another page on the website or refresh the page
- Observe that a
POST /wp-json/pressidium-cookie-consent/v1/consent request is sent on every page visit
Expected behavior
The consent endpoint should only be called:
- The first time the user expresses their consent choice
- Whenever the user changes their consent preferences afterward
The request should not be triggered again on every page load when the consent state remains unchanged.
Screenshots
N/A
Environment (please complete the following information):
- Browser: Tested on Chrome (macOS) and FIrefox (macOS)
- Plugin version:
1.9.1
- WordPress version:
6.9.4
- PHP version:
8.1
Server logs
N/A
Browser console logs
N/A
Checklist
Additional context
N/A
Describe the bug
The client-side of the plugin sends requests to the
POST /wp-json/pressidium-cookie-consent/v1/consentendpoint on every page visit.This happens because the request logic is currently attached to both the
onConsent()andonChange()events, whileonConsent()is triggered on every page load after consent has already been given.As a result, redundant consent requests are sent even when the user’s consent state has not changed.
Steps to reproduce
Detailed steps to reproduce the behavior:
POST /wp-json/pressidium-cookie-consent/v1/consentrequest is sent on every page visitExpected behavior
The consent endpoint should only be called:
The request should not be triggered again on every page load when the consent state remains unchanged.
Screenshots
N/A
Environment (please complete the following information):
1.9.16.9.48.1Server logs
N/A
Browser console logs
N/A
Checklist
Additional context
N/A