%2B在通过$ _COOKIE访问时转换为空间

时间:2014-10-30 16:40:14

标签: php cookies

我正在使用$.cookie

设置Cookie
$.cookie('enc_an', 'awgWTY5CnJr0f4WD0wU4HH+sAupxj459YNb7Q=', {path: '/'});

但是当我在其他页面上回显时,它会给出不同的输出

echo $_COOKIE['enc_an']; //Outputs : awgWTY5CnJr0f4WD0wU4HH sAupxj459YNb7Q=

当我检查cookie值时,它是URL encoded

awgWTY5CnJr0f4WD0wU4HH%2BsAupxj459YNb7Q=

1 个答案:

答案 0 :(得分:1)

By default the cookie value is encoded when writing using encodeURIComponent. This can be bypassed by setting by setting raw to true

$.cookie.raw = true;
$.cookie('enc_an', 'awgWTY5CnJr0f4WD0wU4HH+sAupxj459YNb7Q=', {path: '/'});