Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1258288

    Hi,

    we’ve modified out cookie consent a little, putting our custom PHPSESSID cookie in the ‘essential’ category and disabling the toggles for this category with the following code.

    function enforceTechnicalCookiesMayNotBeDisabled() {
        $output = '';
        $output .= '
             <script>
                 (function ($) {
                        "use strict";            
                     $("#aviaPrivacyCustomCookiePHPSESSIDDisabled").attr("disabled","disabled");
                   	 $("#aviaPrivacyCustomCookiePHPSESSIDDisabled").attr("checked","checked");
                   	 $("#aviaPrivacyRefuseCookiesHideBar").attr("disabled","disabled");
                  	 $("#aviaPrivacyEssentialCookiesEnabled").attr("disabled","disabled");
                     $(document).on("click", ".br-privacyentry a", function() {
                         $(".avia-cookie-consent-button.avia-cookie-info-btn").click();
                     });                  
                 }(jQuery));
     
             </script>
             ';
        echo $output;
    }
    add_action('wp_footer', 'enforceTechnicalCookiesMayNotBeDisabled', 10000);
    add_action('admin_footer', 'enforceTechnicalCookiesMayNotBeDisabled', 10000);

    The overall cookie behaviour is Opt-In; only essential cookies being enabled in the modal.
    Since PHPSESSID is not an essential cookie in itself, we added the attribute checked=”checked” as can be seen in the code above.

    It used to work but I’ve just noticed that the toggle is turned off on the page. When I use the option “Accept all cookies” on the banner, the cookie “PHPSESSIDDisabled” is set with the value “true” which didn’t happen before either.
    The issue is occurring across multiple pages.

    #1259484

    Hey brandreach_at,

    Thank you for the inquiry.

    The script above seems to be working properly. The toggles are correctly disabled on page load and the PHPSESSID is grayed out. Is that how it supposed to work?

    You might also have to change the class attribute of the parent div container of the input element or checkbox from av-cookie-save-unchecked to av-cookie-save-checked.

    Best regards,
    Ismael

    #1260168

    Hi Ismael,

    we’ve moved the cookie banner to a test page, you can find the new login data in the private content field.

    Changing the class of the parent div container seemed to work. We added a little styling for the toggle to make it checked as well.
    This works for accepting all cookies as well as opening the modal and saving settings there.

    However, if you change the cookie settings after initally accepting (main navigation link “cookies” reopens the settings modal), the custom cookie PHPSESSIDDisabled will be true, blocking our cookie. Saving it again will unblock it again, the value switching between true and false. The goal is for it to stay “false” though so PHPSESSID is always allowed (being defined as an essential cookie)

    The classes of the parent div seem to match now, so the problem may lie elsewhere.

    #1260908

    Hi,

    Thank you for the update.

    the custom cookie PHPSESSIDDisabled will be true

    Is it set as true in the local storage, or only in the modal popup window where it is toggled as active instead of grayed out or disabled?

    Why do you have to create a custom toggle for the PHPSESSID when by default it should always be allowed? Instead of creating a toggle, just remove the custom cookie from the theme options and just indicate in the modal popup window or in your privacy section that the site has to store PHP session cookies to make sure that certain features work.

    Best regards,
    Ismael

    #1260918

    Hi Ismael,

    only indicating it and not using it as custom cookie did the trick, thank you!

    We’ve been adding it as custom cookie because of a specification our customer gave us for the cookie banner.

    Since our issue’s been resolved, the topic can be closed, thanks.

    #1261181

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Cookie Consent: Custom essential cookies’ is closed to new replies.