W3 Total Cache
Fragment caching and cookies not working (2 posts)

  1. tausen
    Posted 2 years ago #

    I'm trying to add a box that should be shown until the user ticks it off. I'm using a cookie to determine whether the user has chosen to hide the box and I've wrapped the box in mfunc tags to prevent caching - unfortunately, it seems very sporadic whether this works or not (sometimes it seems to work on some subpages, etc.).

    I'm doing something like this:

    <!-- mfunc mysecretcode -->
    if (!isset($_COOKIE["mycookie"])) {
        echo 'the box goes here, <a onclick="jqueryAjaxSetCookie();">click to hide</a>';
    <!-- /mfunc mysecretcode -->

    It works flawlessly when I'm logged in as admin and caching is disabled - as soon as I'm not, it breaks. I've verified that the cookie is being set using a cookie inspection addon for my browser.

    Anyone have any ideas? Thanks in advance!


  2. tausen
    Posted 2 years ago #

    Temporarily fixed by loading the content via AJAX and adding the URL that is loaded from to the W3TC cache exclude list.

    I consider this a hack and would prefer some working fragment caching, though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • W3 Total Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic