for backwards compatibility in django 2 1 return a dictionary parsed from a cookie header string assume an empty name per https bugzilla mozilla orgshowbug cgi id169091 unquote using python s algorithm for backwards compatibility in django 2 1 return a dictionary parsed from a cookie header string assume an empty name per https bugzilla mozilla org show_bug cgi id 169091 unquote using python s algorithm
from http import cookies


SimpleCookie = cookies.SimpleCookie


def parse_cookie(cookie):
    
    cookiedict = {}
    for chunk in cookie.split(";"):
        if "=" in chunk:
            key, val = chunk.split("=", 1)
        else:
            
            
            key, val = "", chunk
        key, val = key.strip(), val.strip()
        if key or val:
            
            cookiedict[key] = cookies._unquote(val)
    return cookiedict