Django JS Cookie 中文

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/twfb/p/10957312.html