Cyrillic characters from javascript cookie to php output via $_COOKIE

Posted by Beck on Stack Overflow See other posts from Stack Overflow or by Beck
Published on 2010-04-02T10:09:43Z Indexed on 2010/04/02 10:13 UTC
Read the original article Hit count: 557

Filed under:
|
|

When i'm trying to put russian text in cookie via javascript and then output it via php it returns:

%u043F%u0440%u043E%u0432%u0435%u0440%u043A%u0430

How to decode this to normal cyrillic characters?

This is the function i'm using to pass to document.cookie:

function setCookie(c_name,val,c_expiredays,c_path,c_domain,c_secure)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+c_expiredays);
    document.cookie=c_name+ "=" +escape(val)+

    /* Additional settings */

((c_path) ? "; path=" + c_path : "") + ((c_domain) ? "; domain=" + c_domain : "") + // used to allow using only on a certain domain ((c_secure) ? "; secure" : "") + // used for HTTPS (SSL)

    ((c_expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

setCookie('name',$(this).val(),1);

On server side, i'm outputting like that:

(isset($_COOKIE['img_href_value']) ? $_COOKIE['img_href_value'] : '')

© Stack Overflow or respective owner

Related posts about cyrillic

Related posts about cookie