Reputation: 437
ok, so I guess I'm missing something very simple here, but can't manage to store more than one cookie with this function:
function safe_item(name) {
document.cookie = 'item name:' + name;
}
It works exactly as expected, but when a new cookie is created, the previous one just disappears :/
Upvotes: 1
Views: 991
Reputation: 1082
That's because document.cookie
only accepts a single string as value;
So, instead of document.cookie = 'item name:' + name;
, do this document.cookie += 'item name:' + name;
Upvotes: 2