Title: Checking Cookies
Last modified: May 25, 2018

---

# Checking Cookies

 *  Resolved [seemannslohn](https://wordpress.org/support/users/seemannslohn/)
 * (@seemannslohn)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/)
 * 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)

 *  [Mark](https://wordpress.org/support/users/markwt/)
 * (@markwt)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10322931)
 * Hi [@seemannslohn](https://wordpress.org/support/users/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](https://snag.gy/DYwWUK.jpg) and the cookies have been [rejected](https://snag.gy/If9cEu.jpg).
 * 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](https://wordpress.org/support/users/seemannslohn/)
 * (@seemannslohn)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10332609)
 * 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!
 *  [Mark](https://wordpress.org/support/users/markwt/)
 * (@markwt)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10333291)
 * Hi [@seemannslohn](https://wordpress.org/support/users/seemannslohn/)
 * You may check that in PHP like below code
 * `(!empty($_COOKIE["viewed_cookie_policy"]) && $_COOKIE["viewed_cookie_policy"]
   == 'yes'))`
 *  Thread Starter [seemannslohn](https://wordpress.org/support/users/seemannslohn/)
 * (@seemannslohn)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10335803)
 * 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?
 *  [Mark](https://wordpress.org/support/users/markwt/)
 * (@markwt)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10337669)
 * Hi [@seemannslohn](https://wordpress.org/support/users/seemannslohn/),
 * Please see the shortcode list in the attached [screenshot](http://prntscr.com/jo73kw).
   
   Please [leave us a review](https://wordpress.org/support/plugin/cookie-law-info/reviews/?filter=5#new-post)
   if the plugin/support was helpful.

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

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

 * ![](https://ps.w.org/cookie-law-info/assets/icon.svg?rev=3007243)
 * [CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice)](https://wordpress.org/plugins/cookie-law-info/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-law-info/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-law-info/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-law-info/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-law-info/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-law-info/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Mark](https://wordpress.org/support/users/markwt/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/checking-cookies/#post-10337669)
 * Status: resolved