Django
from django.utils.http import urlquote
response.set_cookie('name', urlquote(username))
JS
getCookie (name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return (arr[2]);
else
return null;
}
console.info(decodeURI(getCookie ('name') ))
参考链接:https://www.cnblogs.com/qinghuaL/p/9372634.html
原文:https://www.cnblogs.com/edhg/p/10957312.html