• Resolved markusdittrich

    (@markusdittrich)


    Suppose the following scenario:

    A GDPR-Cookie Plugin uses a cookie to determine whether the user gave consent to the use of cookies AND to which degree he or she did so. The state of the cookie may vary between

    {"strict":"1","thirdparty":"0","advanced":"0"}
    {"strict":"1","thirdparty":"1","advanced":"0"}
    {"strict":"1","thirdparty":"1","advanced":"1"}

    or not being set at all.

    Depending on that state, the plugin allows for the use of hooks in a given WordPress-template to conditionally load content that uses cookies (e.g. a google-maps iframe). For example:

    
    if ( gdpr_cookie_is_accepted( 'thirdparty' ) ) {
        // Here goes the code that echoes the google maps iframe
    }
    

    I know that it’s possible with W3 Total Cache to create a unique cache of a page depending on whether a cookie is set or not by using cookie groups. While this works fine and as expected I fail to set it up in a way that creates a unique cache of a page for each state that cookie may have (so one version of a page where strict cookies are allowed, one where strict cookies _and_ 3rd-party cookies are allowed and so on)

    Is it possible to do something like that?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @markusdittrich,
    Thank you for your inquiry, and I am happy to assist you with this.

    You should use the correct groups and each group should specify {key}={value}
    Depending on what key you are using, that should look like {key}='{"strict":"1","thirdparty":"0","advanced":"0"}'
    So you should replace {key} with the actual cookie name.

    And don’t forget to enable all the checkboxes (enable and cache)

    I hope this helps.

    Thread Starter markusdittrich

    (@markusdittrich)

    Hello @vmarko,

    Thank you for the quick reply! Unfortunately this doesn’t seem to do the trick. Might this have something to do with the fact that the cookie in question doesn’t actually store the nice JSON-string I’ve described but rather an ugly URL-encoded version of it?

    So instead of
    {"strict":"1","thirdparty":"0","advanced":"0"}
    the cookie actually reads
    %7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%220%22%2C%22advanced%22%3A%220%22%7D

    Just to be sure let me describe what I have set up so far:
    So I’ve set up three Cookie Groups:

    gdpr_strict_cookies:
    moove_gdpr_popup='%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%220%22%2C%22advanced%22%3A%220%22%7D'

    gdpr_strict_and_3rd:
    moove_gdpr_popup='%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%221%22%2C%22advanced%22%3A%220%22%7D'

    gdpr_all_cookies:
    moove_gdpr_popup='%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%221%22%2C%22advanced%22%3A%221%22%7D'

    Each group has enabled checkboxes for enable and cache

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @markusdittrich,
    You should remove the single quotes around the values, that should work.

    Thread Starter markusdittrich

    (@markusdittrich)

    Okay so now it’s configured like:

    gdpr_strict_cookies:
    moove_gdpr_popup=%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%220%22%2C%22advanced%22%3A%220%22%7D

    gdpr_strict_and_3rd:
    moove_gdpr_popup=%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%221%22%2C%22advanced%22%3A%220%22%7D

    gdpr_all_cookies:
    moove_gdpr_popup=%7B%22strict%22%3A%221%22%2C%22thirdparty%22%3A%221%22%2C%22advanced%22%3A%221%22%7D

    Unfortunately it still doesn’t work. I should see a version of a page where a google maps iframe is echoed, but all I get is the version that’s supposed to show when the user hasn’t accepted 3rd-party cookies. So it’s either serving a cached version for what’s defined in gdpr_strict_cookies or for what’s defined when there are no cookies enabled at all.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @markusdittrich,

    Sorry about the confusion. As Cookie Groups are Pro Feature of the plugin I must ask you if you have a pro license? If that’s the case, please contact us via the plugin in Performance>support.
    If you do not have the Pro license Cookie Groups will not be available.

    Thread Starter markusdittrich

    (@markusdittrich)

    Ah so that’s the problem! Alright, I’ll ask the client if he’s willing to go pro on this. Just a quick question: Would the plugin stop working after a year or would it just be unable to update?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @markusdittrich,

    It will update after one year is expired.

    Thread Starter markusdittrich

    (@markusdittrich)

    Oh no, what I meant is: If my client doesn’t renew the license, will the plugin still work?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @markusdittrich,

    Sorry for the late reply, I guess I missed this.
    If the license is not renewed the plugin will continue to work but Pro features will be unavailable.

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

The topic ‘Caching with different cookie states’ is closed to new replies.