set cookie with non-english

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux