[Django]-Django cookies place double quotes around email address

4👍

You can try strip method

email.strip('"')
👤errx

-1👍

Another solution for this issue is to directly work with a SimpleCookie object and attach it to your response

>>> from Cookie import SimpleCookie
>>> mycookie = SimpleCookie()
>>> mycookie['emailaddress'] = 'josuebrunel@gmail.com'
>>> mycookie['emailaddress']['expires'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
>>> print(mycookie)
Set-Cookie: emailaddress="josuebrunel@gmail.com"; expires=2015-11-25 22:20:16
>>> response.cookies = mycookies

I had the same issue, and i fixed by using SimpleCookie

Leave a comment