Resolving “Error: invalid nonce”

If you encounter the error message “Error: invalid nonce. Please reload the page and try again. If the problem persists, please contact our support team.” while using Donation Platform for WooCommerce, it typically indicates an issue with nonce verification. Nonces are security tokens used to prevent CSRF (Cross-Site Request Forgery) attacks and ensure the integrity of requests made to the server.

Understanding the Issue

Nonces in Donation Platform for WooCommerce have a default lifetime of one day. When caching plugins are enabled, they may cache HTML pages for longer durations, causing nonces to expire before the user completes the donation process. As a result, users may encounter the “invalid nonce” error when attempting to make a donation.

Troubleshooting Steps

1. Use a Shorter Cache Time

Configure your caching plugin to use a shorter cache time, ideally around 4 hours. This adjustment prevents nonces from expiring too quickly and helps avoid nonce-related errors during the donation process.

2. Disable Cache for Affected Pages

If the “invalid nonce” error occurs on specific pages, consider disabling caching for those pages. Most caching plugins offer options to exclude certain URLs or pages from caching. By excluding donation-related pages from caching, you ensure that nonces remain valid and donations process smoothly.

3. Consider a Different Caching Plugin

If issues persist despite adjusting cache settings, try using a different caching plugin. Not all caching plugins behave the same way, and switching to one that is more compatible with WooCommerce and Donation Platform for WooCommerce may resolve nonce verification problems.

4. Use Cache Purging

Implement cache purging options provided by your caching plugin. This allows you to manually or automatically clear the cache when specific events occur, such as product updates or new donations. By keeping the cache up-to-date, nonce issues are less likely to occur.