cookie policy popup

In this tutorial we are showing how to show cookie policy popup on website to visitors. This is very simple and clean code for cookie policy popup jut copy below code past into your webpage or inside footer file and save it.

javascript code for cookie policy popup

<script>
function setCookie(cname, cvalue, exdays) {
	var d = new Date();
	d.setTime(d.getTime() + (exdays*24*60*60*1000));
	var expires = "expires=" + d.toGMTString();
	document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
	jQuery(".CookiesPolicy").css("display", "none");
}
function getCookie(cname) {
	var name = cname + "=";
	var decodedCookie = decodeURIComponent(document.cookie);
	var ca = decodedCookie.split(';');
	for(var i = 0; i < ca.length; i++)
	{
		var c = ca[i];
		while (c.charAt(0) == ' ')
		{
			c = c.substring(1);
		}
		if (c.indexOf(name) == 0)
		{
			return c.substring(name.length, c.length);
		}
	}
	return "";
}
function checkCookie() {
	var CookiesPolicyValue = getCookie("CookiesPolicyValue");
	if (CookiesPolicyValue != "" && CookiesPolicyValue==1)
	{
		jQuery(".CookiesPolicy").css("display", "none");
	}
	else if (CookiesPolicyValue != "" && CookiesPolicyValue==0)
	{
		jQuery(".CookiesPolicy").css("display", "none");
	}
	else
	{
		jQuery(".CookiesPolicy").css("display", "block");
	}
}
window.onload = checkCookie;
</script>

HTML code for cookie policy popup

<div class="CookiesPolicy animated zoomIn" style="display:none;">
	<div class="left">
		This website and its third party subsidiaries use  <strong><a href="#">cookies</a></strong>. By continuing to browse, you agree to these cookies being set.
	</div>
	<div class="right">
		<button class="allow" onclick="setCookie('CookiesPolicyValue', '1', '20')">ALLOW</button>
		<span class="disallow" onclick="setCookie('CookiesPolicyValue', '0', '1')">NO, THANK YOU</span>
	</div>
</div>

CSS code for cookie policy popup

<style>
.CookiesPolicy{padding: 10px 50px; position: fixed; bottom: 0px; background: #e0e0e0; z-index: 999; display:none; width: 100%; line-height: 50px;}
.CookiesPolicy .left{max-width:77%; float:left; width: auto;}
.CookiesPolicy .right{width:23%; float:left; padding-left:10px;}
.CookiesPolicy .allow{color: #fff !important; background: #2f5ba2; font-weight: 600; border-radius: 4px; padding: 11px 20px !important; margin: 0px;}
.CookiesPolicy .disallow{color: #000000 !important; font-weight: 600; padding: 11px 25px !important; cursor:pointer;}
</style>

Tags: cookie consent popup, cookie consent javascript, cookie consent code, cookie consent examples, cookie popup jquery, bootstrap cookie consent, cookie consent message, gdpr cookie consent javascript, cookie policy popup using javascript, cookie policy popup using jquery, cookie policy popup html, how to show cookie policy popup on website, how to create cookie policy popup

Leave a Reply

Related Posts: You may like

How To Create a Modal Popup With CSS and JavaScript

Get Latitude Longitude from Address

How to make a sticky sidebar on scroll

How to get the value of HTML tag using JS

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.