summaryrefslogtreecommitdiff
path: root/django/http/response.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/http/response.py')
-rw-r--r--django/http/response.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py
index b21b73f247..96c0cae597 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -154,7 +154,7 @@ class HttpResponseBase:
return self._headers.get(header.lower(), (None, alternate))[1]
def set_cookie(self, key, value='', max_age=None, expires=None, path='/',
- domain=None, secure=False, httponly=False):
+ domain=None, secure=False, httponly=False, samesite=None):
"""
Set a cookie.
@@ -194,6 +194,10 @@ class HttpResponseBase:
self.cookies[key]['secure'] = True
if httponly:
self.cookies[key]['httponly'] = True
+ if samesite:
+ if samesite.lower() not in ('lax', 'strict'):
+ raise ValueError('samesite must be "lax" or "strict".')
+ self.cookies[key]['samesite'] = samesite
def setdefault(self, key, value):
"""Set a header unless it has already been set."""