function setCookie (name, value, expirationDays, rootDomain) {
rootDomain = (rootDomain === undefined ? false : rootDomain);
var date = new Date()
date.setTime(date.getTime() + (expirationDays * 24 * 60 * 60 * 1000))
var c = name + '=' + value + ';' + 'expires=' + date.toUTCString() + ';path = /';
if (rootDomain) {
c += "; domain=." + window.location.hostname.split('.').slice(-2).join('.');
}
document.cookie = c;
}
function getCookie (name) {
name += '='
var cookies = document.cookie.split(';')
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i]
while (cookie.charAt(0) == ' ') {
cookie = cookie.substring(1)
}
if (cookie.indexOf(name) == 0) {
return cookie.substring(name.length, cookie.length)
}
}
return ''
}
function deleteCookie (name, rootDomain) {
rootDomain = (rootDomain === undefined ? false : rootDomain);
var c = name + '=;expires=Wed, 01 Jan 1970 00:00:00 UTC; path=/';
if (rootDomain) {
c += ";domain=." + window.location.hostname.split('.').slice(-2).join('.');
}
document.cookie = c;
}