Title: [Plugin: WP Super Cache] Do not cache if cookie present?
Last modified: August 19, 2016

---

# [Plugin: WP Super Cache] Do not cache if cookie present?

 *  [bradsucks](https://wordpress.org/support/users/bradsucks/)
 * (@bradsucks)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-do-not-cache-if-cookie-present/)
 * I’m trying to make WP Super Cache work with a shopping cart (so that if the $
   _COOKIE[‘cartItems’] variable is greater than zero the visitor is served dynamic
   pages).
 * I’ve tried making my own plugin as I’ve read [here](http://wordpress.org/support/topic/200830)
   and [here](http://wordpress.org/support/topic/191851), but I’m not having much
   luck. Here’s my plugin code:
 *     ```
       function wp_supercache_dontcachecart( $string ) {
   
       	if( $_COOKIE[ 'cartItems' ] > 0 ) {
       		$string = 'cartItems';
       	}
   
       	return $string;
       }
       add_cacheaction( 'wp_cache_get_cookies_values', 'wp_supercache_dontcachecart' );
       ```
   
 * Any idea what I’m doing wrong? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-do-not-cache-if-cookie-present/#post-849757)
 * You need to add the “cartItems” cookie name to the .htaccess rules. It should
   work fine then!
 *  Thread Starter [bradsucks](https://wordpress.org/support/users/bradsucks/)
 * (@bradsucks)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-do-not-cache-if-cookie-present/#post-849766)
 * Thanks donncha! I modified both lines in the htaccess to be:
 * RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_|cartItems).*
   $
 * It works a bit better (I think) but it still seems to be a random toss-up whether
   I get a cached page or a dynamic page when I’m logged out and using the shopping
   cart. Not sure why that is…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: WP Super Cache] Do not cache if cookie present?’ is closed to
new replies.

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [cookie](https://wordpress.org/support/topic-tag/cookie/)

 * 2 replies
 * 2 participants
 * Last reply from: [bradsucks](https://wordpress.org/support/users/bradsucks/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-do-not-cache-if-cookie-present/#post-849766)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
