Title: Never send cached pages when using specific cookie
Last modified: August 28, 2020

---

# Never send cached pages when using specific cookie

 *  [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/)
 * I am using external auth+forum for comments, hence the users are not logged into
   WP.
 * Is there a way to never serve cached pages for users with a certain cookie set?(
   Similar to rejected user agents?)
    Those visitors without the cookie should still
   receive the cached pages.
 * Thanks in advance!

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

 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13325775)
 * I know it can be done by adding
 *     ```
       if(isset($_COOKIE['mycookiename'])){
               return;
       }
       ```
   
 * to the page-cache.php somewhere near the top, but I’d rather have some more upgrade-
   proof solution 🙂
 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13329478)
 * Hi [@peter_bepe](https://wordpress.org/support/users/peter_bepe/),
 * Actually, you can specify particular cookies from the “Advanced Options” tab –
   [https://cloudup.com/cNo93cNcrf2](https://cloudup.com/cNo93cNcrf2)
 * Please give it a try and let us know 🙂
 * Cheers,
 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13330832)
 * That was my first try, but even with the cookie, I got served with cached pages.
 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13361246)
 * Hi [@peter_bepe](https://wordpress.org/support/users/peter_bepe/),
 * Sorry for the delay here, it seems a bug with that functionality. We will check
   that out.
 * Thanks for reporting,
 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13363900)
 * Thank you, will happily test the fixed version 🙂
 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13398446)
 * Do you happen to need any help with the testing?
 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400037)
 * Hi [@peter_bepe](https://wordpress.org/support/users/peter_bepe/),
 * I’ve checked this and couldn’t reproduce the issue with a cookie name like `TestCookie`
   What is the cookie name that you want to reject?
 * There might be an issue with the cookie names that using `+` (eg. You have to
   reject `Test_Cookie` for `Test+Cookie`)
 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400270)
 * Thanks for checking it.
    My cookie name is test_member_hash_loggedin. Can the
   object cache responsible for serving the cached pages while the cookie is present?
 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400308)
 * That’s weird. I just checked `test_member_hash_loggedin` and it works as expected.
 * > Can the object cache responsible for serving the cached pages while the cookie
   is present?
 * Nope, I don’t think so!
 * Could you check the configuration file located in `wp-content/pc-config` ([https://cloudup.com/cFXTVULDM-w](https://cloudup.com/cFXTVULDM-w))
   and make sure `rejected_cookies` specified there
 *  Plugin Author [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/)
 * (@m_uysl)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400326)
 * [@peter_bepe](https://wordpress.org/support/users/peter_bepe/)
 * I think the problem is the webserver configuration. If you have apache/Nginx 
   configurations to serving cached files without PHP execution, that might lead
   the problem here.
 * Apache:
 *  `RewriteCond %{HTTP:Cookie} !(wordpressuser_|wordpresspass_|wordpress_sec_|wordpress_logged_in_
   |test_member_hash_loggedin) [NC]`
 * Nginx:
 * `if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in
   |powered_cache_commented_posts| test_member_hash_loggedin") {`
 * I just opened a new issue on GitHub about this – [https://github.com/skopco/powered-cache/issues/57](https://github.com/skopco/powered-cache/issues/57)
    -  This reply was modified 5 years, 7 months ago by [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/).
    -  This reply was modified 5 years, 7 months ago by [Mustafa Uysal](https://wordpress.org/support/users/m_uysl/).
 *  Thread Starter [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * (@peter_bepe)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400368)
 * Hi Mustafa,
    Thanks, I think the .htaccess line was the culprit, since the pc-
   config file had the rejected cookie value.
 * I am still testing it, but I think the cookie name was not added automatically
   by the PoweredCache .htaccess builder function.
 * Will report back once it is fully tested.

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

The topic ‘Never send cached pages when using specific cookie’ is closed to new 
replies.

 * ![](https://ps.w.org/powered-cache/assets/icon.svg?rev=2796939)
 * [Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score](https://wordpress.org/plugins/powered-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/powered-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/powered-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/powered-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/powered-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/powered-cache/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [PeterB](https://wordpress.org/support/users/peter_bepe/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/never-send-cached-pages-when-using-specific-cookie/#post-13400368)
 * Status: not resolved