Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6657 -- Don't set secure attribute on cookie if `secure=False`…

… is passed, thanks Gulopine.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7204 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4d6f0f26508eea4a16adc4de613777b82701fd31 1 parent 444b7b2
@gdub gdub authored
Showing with 11 additions and 5 deletions.
  1. +11 −5 django/http/__init__.py
View
16 django/http/__init__.py
@@ -314,12 +314,18 @@ def items(self):
def get(self, header, alternate):
return self._headers.get(header.lower(), (None, alternate))[1]
- def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
+ def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False):
self.cookies[key] = value
- for var in ('max_age', 'path', 'domain', 'secure', 'expires'):
- val = locals()[var]
- if val is not None:
- self.cookies[key][var.replace('_', '-')] = val
+ if max_age is not None:
+ self.cookies[key]['max-age'] = max_age
+ if expires is not None:
+ self.cookies[key]['expires'] = expires
+ if path is not None:
+ self.cookies[key]['path'] = path
+ if domain is not None:
+ self.cookies[key]['domain'] = domain
+ if secure:
+ self.cookies[key]['secure'] = True
def delete_cookie(self, key, path='/', domain=None):
self.set_cookie(key, max_age=0, path=path, domain=domain,
Please sign in to comment.
Something went wrong with that request. Please try again.