JQuery stop html cookie

I am using this short code snippet:

var d = itemID + "," + quantity; var CookieData = $.cookie("storebasket"); if(CookieData == null || CookieData == "") { $.cookie("storebasket", d, { path: '/', expires: 60 }); } else { $.cookie("storebasket", CookieData + "|" + d, { path: '/', expires: 60 }); } 

However, the ALLWAYS value becomes HTML encoded. For instance:

 5%2C1 

What when decoding with this tool :

 5,1 

I tried using unescape but no luck:

 $.cookie("storebasket", unescape(d), { path: '/', expires: 60 }); 

Any ideas?

+6
source share
2 answers

jquery.cookie encodes the comma by default. To undo this, simply do:

 $.cookie.raw = true; 
+9
source

This answer is really helpful:

Cookies allowed characters

But I really don't see the problem. If you want to use them in your document, you can delete them. If you want to save them in cookies, they will be escaped.

0
source

Source: https://habr.com/ru/post/913445/


All Articles