Hi everyone

in my PHP code I use the following command to set a cookie with
non-english word (UTF-8) :

@setcookie ("UserName",$Check[1]);

and in my html page I get this cookie using javascript :

<script charset="UTF-8"  type="text/javascript">
<!--
function getCookie (name)
{

   var dc = document.cookie;
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if (begin == -1) {
       begin = dc.indexOf(prefix);
       if (begin != 0) return null;
   } else {
       begin += 2;
   }
   var end = document.cookie.indexOf(";", begin);
   if (end == -1) {
       end = dc.length;
   }
   return unescape(dc.substring(begin + prefix.length, end));

}
var UserName = getCookie("UserName");
document.write(UserName);

--> </script>

but the result from writing the cookie using javascript is garbage, I
don't get the right word !!

anyone know how to resolve it ?

BTW:
* I also tried the php function setrawcookie and I get the same problem
* I use <META http-equiv=Content-Type  content="text/html;
charset=utf-8"> in my page

--

Ahmad Fahad AlTwaijiry

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to