Gazelle/static/functions/cookie.class.js

24 lines
555 B
JavaScript
Raw Normal View History

2011-03-28 14:21:28 +00:00
/*
TODO: Document.
*/
"use strict";
var cookie = {
get: function (cookie_name) {
var value = document.cookie.match('(^|;)?' + cookie_name + '=([^;]*)(;|$)');
return (value) ? value[2] : null;
},
set: function (cookie_name, value, days) {
var date = new Date();
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
if (days === undefined) {
days = 365;
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = cookie_name + "=" + value + "; expires=" + date.toGMTString() + "; path=/";
},
del: function (cookie_name) {
cookie.set(cookie_name, '', -1);
}
};