Get cookie by name
I have a getter to get the value from a cookie.
Now I have 2 cookies by the name and by the name . shares=
obligations=
I want to make this getter only to get the values from the obligations cookie.
How do I do this? So the splits the data into separate values and puts it in an array.for
function getCookie1() {
// What do I have to add here to look only in the "obligations=" cookie?
// Because now it searches all the cookies.
var elements = document.cookie.split('=');
var obligations= elements[1].split('%');
for (var i = 0; i < obligations.length - 1; i++) {
var tmp = obligations[i].split('$');
addProduct1(tmp[0], tmp[1], tmp[2], tmp[3]);
}
}