Newer
Older
import jQuery from 'jquery';
/* eslint-disable-next-line import/prefer-default-export */
export function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; ++i) { /* eslint-disable-line no-plusplus */
const cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) { /* eslint-disable-line prefer-template */
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}