• Resolved lozguiel

    (@lozguiel)


    Hi. I’m trying to set some cookies and everything works fine when the ?swcfpc=1 parameter is added. As soon as I’m not logged in, the cookie won’t set. How can I get around this? Am I being real stupid and missing something obvious (sorry, it’s been a very long week).

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi @lozguiel,
    When you are using the ?swcfpc=1 cache buster query param, your pages are always bypassed from Cache. Now if you are setting cookies at the PHP level then I will highly recommend you not to do it. Cause as soon as you set cookies and there is a set-cookie header in the page response, Cloudflare will not cache that page as it will think that the cookie value might be used inside the webpage to show content dynamically.

    Instead, you should use JavaScript. In JS you can either take advantage of LocalStorage API to store things or you can set cookies using JS in both of these cases cache behaviour will not be hampered.

    In your current case, if you purge the cache of your entire website and I’m sure you will start seeing the cookie you have added at the PHP level.

    Thread Starter lozguiel

    (@lozguiel)

    That’s brilliant! Thanks very much for your help. I think the JS solution will be perfect 🙂

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @lozguiel,
    Happy to help. 🙂

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

The topic ‘Cache stopping set cookie’ is closed to new replies.