Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery stop HTML encoding cookie

I'm using this short snippet of code:

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 value ALWAYS becomes HTML encoded. For example:

5%2C1

Which when decoded with this tool is:

5,1

I've tried using unescape but no luck:

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

Any more ideas?

like image 949
Tom Gullen Avatar asked Apr 17 '12 17:04

Tom Gullen


1 Answers

jquery.cookie is encoding the comma by default. To override this just do:

$.cookie.raw = true;
like image 125
brad oyler Avatar answered Nov 15 '22 04:11

brad oyler