var date = new Date(new Date().getTime() + 5 * 60 * 1000); document.cookie = "bb-2017=value; path=/; expires=" + date.toUTCString(); alert(document.cookie); function deleteCookie(name) { document.cookie.split(";").forEach(function(el) { el = el.split("=")[0].trim(); if(!el.indexOf(name)) { var date = new Date(0); document.cookie = el + "=; path=/; expires=" + date.toUTCString(); } }); } deleteCookie("bb") ; alert(document.cookie);