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

Your email address will not be published. Required fields are marked *

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

JavaScript timer countdown days hours minutes seconds

JavaScript validation on image field

html5 video tag Complete Guide

Getting The Screen Resolution Using JavaScript

How to create textbox in html dynamically using javascript

how to disable right click using JavaScript

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Free online tool to download Instagram videos, photos and save Instagram videos, photos to your device. It's free & easy to use.

Download Now

CURRENCY CONVERTER

Our real time currency converter calculator will convert your money based on current values from around the world. It's free & easy to use.

Convert Now

ROBOST.TXT GEN.

Create robots txt file that help search engines to crawling and indexing your site with help of our free online Robots.txt Generator tool.

Create Now

HTML MINIFIER

Free online tool to minify or compress html code and reduce the size of html code in few clicks. It's free & easy to use.

Minify Now

CSS MINIFIER

Free online tool to minify or compress css code and reduce the size of css code in few clicks. It's free & easy to use.

Minify Now

JAVASCRIPT MINIFIER

Free online tool to minify or compress javascript code and reduce the size of javascript code in few clicks. It's free & easy to use.

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.