Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1310007

    Hello,

    I am developing a website and I would like to whitelist a cookie that I store myself. But the problem is that when a visitor visits the website for the first time the cookie is deleted because it’s deposit wasn’t authorize. Is it possible not to delete this particular cookie? If so, can you explain me how to achieve this ?

    Thanks,
    Regards.

    #1310011

    Hey leplusweb,

    Refer to the following:

    https://kriesi.at/support/topic/possible-to-allow-custom-essential-cookie/#post-1218738

    Best regards,
    Jordan Shannon

    #1310226

    Hey Jordan,

    Thanks for your answer.
    I tried your solution just like in your documentation :

    Kriesi doc

    I’m able to add a toggle button into the privacy policy page to accept / refuse the cookie but it doesn’t resolve my problem which was to prevent the deletion of my custom cookie when someone visits the site for the first time and have not yet accepted the cookie bar.

    My custom cookie is stored in PHP when a visitor visit the website with a specific GET parameter but is immediately deleted by enfold script (avia-snippet-cookieconsent.js I think). I thought to oveloard this script into my child theme but to achieve this I need to overload the helper-privacy.php file located into Enfold > includes but I haven’t succeed so far. I copy the helper-privacy.php file into Enfold_child > includes but the file doesn’t seem to be overload. Is it possible to overload this file ? And if so, do you have a solution to achieve this ?

    Best Regards,
    Le Plus du Web

    #1310623

    Hi,

    Thank you for the info.

    Did you try the suggestion about the Default Cookie Behavior in the previous thread? This should allow all cookies on page load but users will still have the option to disable or enable them via the privacy buttons or the privacy modal popup window if it is enabled.

    Best regards,
    Ismael

    #1310708

    Hi Ismael,

    Yes i tried your suggestion about the Default Cookie Behavior. Indeed, the cookie is by default accepted and present when the visitor visit the website for the first time.

    But if he refuse the cookie, it will be deleted.

    I would like the cookie to be essential and do not allow the users to refuse and delete it.

    Best regards,
    Le Plus du Web

    #1310816

    Hi,

    I would like the cookie to be essential and do not allow the users to refuse and delete it.

    This is possible but you will have to edit the themes/enfold/js/avia-snippet-cookieconsent.js script directly and include the name of the cookie that you want to keep in the list or array (keep_cookies). You can find the following code around line 480.

    if( accepted && allow_hide_bar )
    				{
    					keep_cookies.push( 'aviaCookieConsent', 'aviaPrivacyRefuseCookiesHideBar', 'aviaPrivacyMustOptInSetting' );
    				}
    				else if( accepted )
    				{
    					keep_cookies.push( 'aviaCookieConsent', 'aviaPrivacyMustOptInSetting' );
    				}
    

    Include the name of the cookie that you want to keep in the keep_cookies array.

    Best regards,
    Ismael

    #1310899

    Hi Ismael,

    Thank you for your answer. Your solution works fine but if I update Enfold the changes will be lost so I did these changes into my child theme . If someone wants to do the same thing here is how I procceed :
    First I dequeue the avia-cookie-snippet.js script, I copy the content of this script and paste it into a new file in my child theme. Then I register and enqueue the new script and fill the keep_cookie array with the name of my custom cookie. Here is the code to dequeue avia-cookie-snippet.js and enqueue the new one.

    add_action('wp_enqueue_scripts', 'custom_js');
    function custom_js()
    {
        // Dequeue Enfold cookie script
        wp_dequeue_script('avia-cookie-js');
        wp_deregister_script('avia-cookie-js');
    
        // Enqueue the new cookie script
        wp_register_script('avia-cookie-js', '/wp-content/themes/enfold_child/js/cookies.js', ['avia-default'], '1.0', true);
        wp_enqueue_script('avia-cookie-js');
    }

    Thanks a lot for your answers and have a good day !
    Best regards,
    Le Plus du Web

    #1311105

    Hi,

    Great, I’m glad that you found a solution, and thanks for sharing it :-)

    Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.