Answer the question
In order to leave comments, you need to log in
How to get all COOKIES with NAME starting with WORD?
When users click "add to favorites" a cookie is created like:
name: like_id - where id is either from 1 to 6 digits, or 'undefined'
value: 1 I
form a link like:
site.com?ids=id1+id2+id3
function favorite() {
var arrCook = document.cookie.split(';');
var likeCook = arrCook.filter(function(c) {
return c.trim().indexOf('like_') === 0;
});
var mapArr = likeCook.map(function(c) {
var subresult = c.match( /like_(.*)=1/ );
return subresult[1];
});
var args = Array.prototype.slice.call(mapArr);
var result = args.join('+');
if (result !== '') {
$("#menu").prepend('<li id="menu_favorite"><a href="http://site.com?ids=' + result + '&favorite">Избранное</a></li>');
}
}
favorite();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question