Reputation: 4512
On my login script it creates a cookie for the user logging in of their email address and password. Problem I am having is when the email address is set it puts the entire email address between double quotes. How would I get it to not?
if request.method == 'POST':
post = request.POST
email = post.get('email', None)
response.set_cookie('emailaddress', email, max_age=expire_v)
Upvotes: 4
Views: 1787
Reputation: 1141
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'] = '[email protected]'
>>> mycookie['emailaddress']['expires'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
>>> print(mycookie)
Set-Cookie: emailaddress="[email protected]"; expires=2015-11-25 22:20:16
>>> response.cookies = mycookies
I had the same issue, and i fixed by using SimpleCookie
Upvotes: -1