I using jquery cookie plugin and here are my codes:
$('.Bookmark').click(function () {
var id = $(this).attr('rel');
if ($(this).hasClass('RedHeart')) {
$(this).removeClass('RedHeart');
$.removeCookie('Bookmarkid_' + id, id);
$(this).attr('title', 'Add');
} else {
$(this).addClass('RedHeart');
$.cookie('Bookmarkid_' + id, id, { expires: 3650 });
$(this).attr('title', 'remove');
}
});
$('.Bookmark').each(function () {
var id = $(this).attr('rel');
var $this = $(this);
if ($.cookie('Bookmarkid_' + id) == id) {
$this.addClass('RedHeart');
$this.attr('title', 'remove');
}
});
I'm wondering how can I find all cookies that set with a similar name. for example I set set 3 cookies with these names:
Bookmarkid_3132509
Bookmarkid_3432502
Bookmarkid_4433342
now I want to find and return all cookies that start with Bookmarkid_
name. I need something like this:
if ($.cookie().indexOf("Bookmarkid_") === 0) {
alert('yes')
}
Edit: it's not duplicate and not related to that topic, Still not solved my problem!!!