fix javascript header manipulation cookies

Job ID: 34781320

Budget: $12 – $30 SGD

i would like to fix a javascript header manipulation cookies .
based on https://www.learn-codes.net/javascript/how-to-fix-header-manipulation-cookies-using-javascript/
need to encodeURIComponent() while setCookie() and decodeURIComponent while getCookie().

Please refer to the attachment .js ,open it and read.
I think set cookie is very straight forward ,i think the fix should be like

document.cookie=encodeURIComponent(cname)+"="+encodeURIComponent(cvalue)+";

However,I feel confuse where suppose to add decodeURIComponent().
Related categories: JavaScript jQuery / Prototype