Source
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
var cookie = {
cookies: [],
// Encoding values separated by a comma (%2C), makes the cookie very large in size. A dot, however, remains a dot.
delimiter: '.',
init: function() {
var allCookies = document.cookie.split('; ');
for (var i = 0; i < allCookies.length; i++) {
var cookiePair = allCookies[i].split('=');
this.cookies[decodeURIComponent(cookiePair[0])] = decodeURIComponent(cookiePair[1]);
}
},
create: function(name, value, days) {
var expires = '';
if (typeof(days) !== 'undefined') {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = '; expires=' + date.toGMTString();
}
document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + expires +
(location.protocol === 'https:' ? '; secure' : '');
// Apache header size limit.
if (document.cookie.length > 8000) {
document.cookie = encodeURIComponent(name) + '=;';
alert(t('S_MAX_COOKIE_SIZE_REACHED'));
return false;
}
else {
this.cookies[name] = value;
}
return true;
},
createArray: function(name, value, days) {
var part_string = '',
part_length = 0,
part = 0,
prev_part_count = parseInt(this.read(name + '_parts'), 10);
if (is_null(prev_part_count)) {
prev_part_count = 1;
}
for (var i = 0; i < value.length; i++) {
var is_last = (i === value.length - 1),
curr_value = value[i];
if (!is_last) {
curr_value += this.delimiter;
}
var curr_length = encodeURIComponent(curr_value).length;
if (part_length + curr_length <= 4000) {
part_string += curr_value;
part_length += curr_length;
}
else {
part++;
if (!this.create(name + '_' + part, part_string, days)) {
break;
}
part_string = curr_value;
part_length = curr_length;
}
if (is_last) {
part++;