Snippets Collections
 for(let button of cookieBtns){
                button.addEventListener('click', function(){
                    if(this.matches('.accept')){
                        if(cookieContainer.classList.contains('show')){
                            cookieContainer.classList.remove('show');
                            setCookie('site_notice_dismissed', 'true', 30);
                            setCookie('testing', true, 30)
                        }
                    }
                    
                    if(this.matches('.decline')){
                         if(cookieContainer.classList.contains('show')){
                            cookieContainer.classList.remove('show');
                            eraseCookie('site_notice_dismissed');
                        }
                    }
                })
 }




function cookieBtnUpdate() {
    
            const cookieBtns = document.querySelectorAll('button[data-cookie="btn"]');
            const cookieContainer = document.querySelector('.smp-global-alert');
           
           
           // functions
           function setCookie(name,value,days) {
            var expires = "";
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days*24*60*60*1000));
                expires = "; expires=" + date.toUTCString();
            }
            
            document.cookie = name + "=" + (value || "")  + expires + "; path=/";
            }
            
            function eraseCookie(name) {   
            document.cookie = name+'=; Max-Age=-99999999;';  
            }


            //event on buttons
            for(let button of cookieBtns){
                button.addEventListener('click', function(){
                    if(this.matches('.accept')){
                        console.log(this)
                    }
                    
                    if(this.matches('.decline')){
                         console.log(this)
                    }
                })
            }
            
            
}


cookieBtnUpdate();
function mind_set_cookie_expire( $time ) {

return time() + 86400;  // 1 day

}

add_filter( 'post_password_expires', 'mind_set_cookie_expire' );
window.location.search.includes('cro_mode=qa')

// or

window.location.search.indexOf('cro_mode=qa') > -1

// finding it in cookies: 
function getCookie(name) {
  const value = `; ${document.cookie}`;
  const parts = value.split(`; ${name}=`);
  if (parts.length === 2) return parts.pop().split(';').shift();
}
//then...
getCookie('cro_mode')

//or something like ...
  const parts = document.cookie.split('cro_mode');
  if (parts.length === 2) {console.log(parts.pop().split(';').shift())}
<script data-cookieconsent="ignore">
    window.dataLayer = window.dataLayer || [];
    function gtag() {
        dataLayer.push(arguments);
    }
    gtag("consent", "default", {
        ad_storage: "denied",
        analytics_storage: "denied",
        functionality_storage: "denied",
        personalization_storage: "denied",
        security_storage: "granted",
        wait_for_update: 2000,
    });
    gtag("set", "ads_data_redaction", true);
</script>
const str  = 'mycookie=test';

const spl = str.split(';');

const x = spl.map(v => v.split('='))
.map(([k, ...vs]) => [k, vs.join('=')]).reduce((acc, [k, v]) ={
       acc[k.trim()] = decodeURIComponent(v);
       return acc;
 }, {});

console.log(x);
star

Sun Mar 09 2025 21:41:12 GMT+0000 (Coordinated Universal Time)

#cookie
star

Mon Apr 24 2023 05:43:06 GMT+0000 (Coordinated Universal Time) https://passwordprotectwp.com/wordpress-password-protected-page-cookie/

#password #cookie
star

Tue Feb 14 2023 21:44:06 GMT+0000 (Coordinated Universal Time)

#test #cookie
star

Fri Oct 22 2021 16:17:25 GMT+0000 (Coordinated Universal Time) https://support.cookiebot.com/hc/en-us/articles/360016047000

#cookie #consent #script #head #tracking
star

Sat Aug 07 2021 04:35:46 GMT+0000 (Coordinated Universal Time) https://jsbin.com/

#cookie #js

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension