HTML:
CSS:
JS:
Kod:
<div id="cerez-durum" class="cookies-wrap js-cookie-consent">
<div class="cookies" style="display:block;">
<section>
<strong>ÇEREZ POLİTİKASI</strong>
<article>Bu sitenin doğru çalışması için çerezler (cookies) kullanılmaktadır. </article>
<div class="cookies-ok">
<a href="#">Detaylı Bilgi</a>
<i class="js-cookie-consent-agree" onclick="acceptCookieConsent();">Kabul Ediyorum</i>
</div>
</section>
<div class="cookies-close" onclick="acceptCookieConsent();"><span>x</span></div>
</div>
</div>
CSS:
Kod:
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
@import url('https://fonts.googleapis.com/css2?family=Mulish:wght@300;400;500;600&display=swap');
* {
padding: 0;
margin: 0;
list-style: none;
border: 0;
text-decoration: none;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
font-family: 'Mulish', sans-serif;
transition:300ms all;
}
body {
background-color: #d9d9d9;
}
.cookies { position:fixed; right:20px; bottom:20px; width:280px; padding:20px 25px; background-color:rgba(233, 34, 35, 0.9); font-size:12px; color:rgba(255, 255, 255, 0.8); z-index:6500; border-bottom:2px solid #000; border-radius:6px; }
.cookies section { float:left; width:100%; }
.cookies strong { float:left; width:100%; margin:-5px 0 5px 0; font-size:14px; }
.cookies article { float:left; width:100%; }
.cookies a { color:#FFF; font-weight:500; }
.cookies a:hover { text-decoration:underline; }
.cookies-ok { float:left; width:100%; margin-top:14px; line-height:30px; }
.cookies-ok a { float:left; margin-right:20px; color:#FFF; text-decoration:underline; }
.cookies-ok a:hover { text-decoration:none; }
.cookies-ok i { font-style: normal; float:left; padding:0 25px; background-color: #000; font-weight:600; border-radius:15px; cursor:pointer; }
.cookies-ok i:hover { color:#ea3738; background-color:#FFF; }
.cookies-close { position:absolute; top:-12px; right:20px; width:24px; height:24px; }
.cookies-close span {text-align: center; line-height: 20px; color:#fff; float:left; width:100%; height:100%; position:relative; background:#000; cursor:pointer; border-radius:50%; }
JS:
Kod:
// Create cookie
function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// Delete cookie
function deleteCookie(cname) {
const d = new Date();
d.setTime(d.getTime() + (24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=;" + expires + ";path=/";
}
// Read cookie
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
// Set cookie consent
function acceptCookieConsent(){
deleteCookie('user_cookie_consent_tr_wp_1');
setCookie('user_cookie_consent_tr_wp_1', 1, 30);
document.getElementById("cerez-durum").style.display = "none";
}
let cookie_consent = getCookie("user_cookie_consent_tr_wp_1");
if(cookie_consent != ""){
document.getElementById("cerez-durum").style.display = "none";
}else{
document.getElementById("cerez-durum").style.display = "block";
}