April 4, 2012
How to write a non-english character cookie using javascript and let php reads it properly
Question by Sami Al-Subhi
my websites sometimes needs to read a javascript cookie using php but sometimes I get weird character set from some users like this `#16 3CFJ) DD%J,’1 while for some users it reads it properly. therefore, I think the problem is in the client-side. I use this method to write cookies:
var expireDate = new Date();
expireDate.setMonth(expireDate.getMonth() + 1);
var value="Sami";
document.cookie = "name="+value+";path=/;expires="+expireDate.toGMTString();
and this $_COOKIE['name']
to read it using php.