Is there a way to set cookies with the same name for multiple domains or paths in the same response? The following only sets the second cookie:
response.set_cookie("alice", "123", domain='sub.example.com')
response.set_cookie("alice", "456", domain='example.com')
I looked at the Django implementation. It uses a dictionary for storing cookies:
self.cookies[key] = value
So Django cannot set multiple cookies with the same name in the same response.
Is this intended to work that way? Do you see a way to work around that limitation?
Update
Reported as a bug: https://code.djangoproject.com/ticket/18908
This may not be exact answer to the question, but still.
This seems issue with the django implementation, as it is only using cookie name as a key in dict.
In real world, one can have cookies with same name with multiple values, provided either domain or path differs. I found this useful HTTP cookies explained
More Reference:
RFC2965
Http Cookie