1. Home
  2. Getting Started
  3. Troubleshooting Caching & Session Issues

Troubleshooting Caching & Session Issues

Sometimes you or your site visitors might experience issues related to caching or sessions while using WP Simple Pay. In most cases, this is because your web host has it’s own caching rules in place or you have a caching plugin configured on your site. Both are good things for your site’s overall load times and performance but can block some of the checkout messaging of WP Simple Pay.

How to Detect a Caching or Session Issue

If you or your site visitors are seeing the following message after completing payments, yet you’re seeing these payments go through in your Stripe dashboard, it’s usually a caching or session-related issue.

An error occurred, but your charge may have gone through. Please contact the site admin.

Excluding Confirmation Pages from Cache

To resolve this issue, you’ll need to make sure your payment success and failure pages are excluded from any site caching.

With some web hosts such as WP Engine, you’ll need to contact your host and let them know to exclude these pages (URLs) from caching.

If you’re using a caching plugin, you may need to specify which pages to exclude from caching. By default, WP Simple Pay turns off caching for the payment success and failure pages by using the standard DONOTCACHEPAGE constant. Most popular WordPress caching plugins will detect this constant and disable caching on these pages if it’s set to true. If you need to specify additional page cache exclusions via code, you can start with this filter hook example from our code snippet library.

Purging the Site Cache

Server-Side Cache

Some web hosts will use advanced caching techniques to automatically make your site run more smoothly. This is great, but you might find that sometimes you will need to purge this cache to make sure your forms are using the latest version of the plugin files. You will want to look around in your WordPress admin for some kind of “purge cache” button to clear this all out. If you cannot find one then you can contact your host to ask them for assistance. Below is an example of how this looks for SiteGround.

Browser Cache

Some website changes might require you to clear the browser cache. This mostly affects JavaScript changes and usually when you are making frequent updates and testing. These will most likely never be a problem for you, but it is good to be aware just in case.

The best solution for this is to just clear the browser cache and then reload the page. Some browsers, such as Google Chrome, let you perform a “hard reload” of the page. To do this in Chrome, first open the console log window (Cmd-Alt-J or F12). Next, right-click the reload button and select “Empty Cache and Hard Reload”. Similar functionality should exist in other browsers as well.

Switching to Native PHP Sessions

If you’re still getting the above error message after troubleshooting caching issues, it may be a session issue.

By default, WP Simple Pay overrides the use of native PHP sessions and uses a custom table temporary storage method instead. This is to improve performance and is common practice both in WordPress core as well as other e-commerce plugins.

In a few cases, this method may not work with some hosting configurations. To force the use of native PHP sessions, you’ll need to add this constant to your wp-config.php file.

define( 'SIMPLE_PAY_USE_PHP_SESSIONS', true );

If needed, see how to edit your wp-config.php file. Alternatively, you can use the simpay_use_php_sessions filter hook.

Note for Pantheon Customers

After extensive testing with various popular web hosts, the only host where our method of overriding native PHP sessions didn’t work was with Pantheon.

If you host with Pantheon, they prefer to override and handle PHP sessions in a method specific to their server architecture, again for performance reasons.

In short, you simply need to install their free Native PHP Sessions plugin on your Pantheon-hosted sites. In turn, WP Simple Pay will detect if this plugin is active and defer to it’s handling of PHP sessions.

Updated on January 31, 2019

Was this article helpful?

Related Articles