• Resolved seemannslohn

    (@seemannslohn)


    You said: “Plugin will show a notice with Accept and Reject options. By default the cookie value will be set to ‘null’. If the user clicks ‘Accept’ button the value with be changed to ‘yes’. IF the user clicks on ‘Reject’ the value will be set to ‘no’. Your developer can check this value to set a cookie”

    How is it possible to check “null”, “yes” and “no”, perhaps with PHP? Is there a shortcode oder function which can be used? How do I get the cookie setup?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @seemannslohn,

    When a user accepts a cookie, the value of the cookie viewed_cookie_policy will be set “yes” and if rejects the value of the cookie will be “no”. By default, the value of the cookie is “null”. This can be viewed from the developer console when the cookies have been accepted or rejected and the page has been reloaded.

    See the screenshot of the value of viewed_cookie_policy, when the cookies are accepted and the cookies have been rejected.

    When the value of viewed_cookie_policy is “yes” the corresponding scripts will be rendered. As in the below JS code for Google Analytics, here it will enable for GA if the consent is yes. i.e., the value of the viewed_cookie_policy is “yes”.

    <script type="text/javascript"
     src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js">
    var consent_value = $.cookie("viewed_cookie_policy");
    
            if (consent_value == 'yes')
            {
                enableGoogleAnalytics(); // enable GA inside this function
            }
    Thread Starter seemannslohn

    (@seemannslohn)

    First: Thanks for your very (!) quick answer.

    But I’m sorry, I didn’t get it. Which code do I have to include in my WordPress-PHP-Files?

    My idea is to use this syntax:

    <?php
    if (consent_value == ‘yes’)
    {
    echo (‘Cookies are accepted’);
    {
    ?>

    But the question is: Where and how can I define the var: consent_value, so that I can check it via php if?

    Thanx a lot für your patience!

    Hi @seemannslohn

    You may check that in PHP like below code

    (!empty($_COOKIE["viewed_cookie_policy"]) && $_COOKIE["viewed_cookie_policy"] == 'yes'))

    Thread Starter seemannslohn

    (@seemannslohn)

    Thank you very much. It works:

    (!empty($_COOKIE[“viewed_cookie_policy”]) && $_COOKIE[“viewed_cookie_policy”] == ‘yes’)

    I am happy! 🙂

    One last question: Is there also a [shortcode] I can use in pages?

    Hi @seemannslohn,

    Please see the shortcode list in the attached screenshot.
    Please leave us a review if the plugin/support was helpful.

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

The topic ‘Checking Cookies’ is closed to new replies.