JS/JQuery - Cookies
Work with cookies the easy way.
function setCookieWithTime(key, value, expires) {
document.cookie = key + '=' + value + ';expires=' + expires.toGMTString();
}
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (5 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toGMTString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
function setCookieWithTime(key, value, expires) {
document.cookie = key + '=' + value + ';expires=' + expires.toGMTString();
}
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (5 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toGMTString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
Comments
Post a Comment