Python Flask set cookie for both example.com and www.example.com

cookies, flask, python

Solution

Ah! set_cookie() has a domain parameter.

response.set_cookie('name', 'value', domain='.example.com')

Problem solved.

Problem

I'm trying to return a response that sets a cookie for example.com and www.example.com. I've only been able to set the cookie for the domain the request originates from. Can someone point me in the right direction?

Original source