function CreateCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else
var expires = "";
document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/";
}
function ReadCookie(name) {
var nameEscape = escape(name) + "=";
var cookieSplit = document.cookie.split(';');
for (var i = 0; i < cookieSplit.length; i++) {
var c = cookieSplit[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEscape) == 0) return unescape(c.substring(nameEscape.length, c.length));
}
return null;
}
function DeleteCookie(name) {
CreateCookie(name, "", -1);
}
Hope it helps !!
How to set/unset cookie with Javascript
Browser cookies is old school but a lot of companies are still using cookies to track the users or to store information temporarily in the browser. Below javascript snippet to get/set or delete the cookies associated with the current domain.