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

Get Latitude Longitude from Address

How to make a sticky sidebar on scroll

How to get the value of HTML tag using JS

JavaScript timer countdown days hours minutes seconds

Tools:

Crypto Currency

PHPKIDA provides free online the best real-time crypto market price, news, predictions, index with graphs & historical data for 2000+ coins including bitcoin, ethereum, & altcoins from major cryptocurrency exchanges.

Visite Tool

Icon Generator

PHPKIDA provides free online icon generator. Our icon generator help you to edit, modify, resize and customize icon for your website and applications. Convert to a shap you like add icon border, you can change icon border color, border size, background color, icon shadow, icons color, icon size in your own way and save it as a png image.

Visite Tool

Youtube Video Downloader

PHPKIDA provides Free online YouTube video downloader to download YouTube videos quickly in MP4, 3GP, and more. Search your video and free fast download youtube videos.

Visite Tool

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.