I have written a jquery adding and removing a cookie but I seem to have an issue when removing a specific cookie
Basically this is the code where I insert a cookie inside an array:
var my_array = [];
$(".addCookie a").click(function(e) {
var val = $(this).attr("href");
if (my_array.indexOf(val) == -1) { my_array.push(val); }
$.cookie('Cookies', my_array);
e.preventDefault();
return false;
});
The above works perfectly, where a value is added as a cookie to my array list like this
74851%2C48877%2C55669
Now in my delete cookie when I try to remove a specific cookie like 48877 from my array
list the whole array list is deleted?
Not sure where I am going wrong in my code?
$(".delcookie a").click(function(e) {
var val = $(this).attr("href");
if (my_array.indexOf(val) > -1) {
$.cookie('Cookies', val, { expires: -1 });
}
e.preventDefault();
return false;
});
Please advice?
This post has been edited by kevin_911: 23 September 2012 - 10:48 AM

New Topic/Question
Reply


MultiQuote





|