Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Gary Wilson Jr. authored March 08, 2008

Showing 1 changed file with 11 additions and 5 deletions. Show diff stats Hide diff stats

  1. 16  django/http/__init__.py
16  django/http/__init__.py
@@ -314,12 +314,18 @@ def items(self):
314 314
     def get(self, header, alternate):
315 315
         return self._headers.get(header.lower(), (None, alternate))[1]
316 316
 
317  
-    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
  317
+    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False):
318 318
         self.cookies[key] = value
319  
-        for var in ('max_age', 'path', 'domain', 'secure', 'expires'):
320  
-            val = locals()[var]
321  
-            if val is not None:
322  
-                self.cookies[key][var.replace('_', '-')] = val
  319
+        if max_age is not None:
  320
+            self.cookies[key]['max-age'] = max_age
  321
+        if expires is not None:
  322
+            self.cookies[key]['expires'] = expires
  323
+        if path is not None:
  324
+            self.cookies[key]['path'] = path
  325
+        if domain is not None:
  326
+            self.cookies[key]['domain'] = domain
  327
+        if secure:
  328
+            self.cookies[key]['secure'] = True
323 329
 
324 330
     def delete_cookie(self, key, path='/', domain=None):
325 331
         self.set_cookie(key, max_age=0, path=path, domain=domain,

0 notes on commit 4d6f0f2

Please sign in to comment.
Something went wrong with that request. Please try again.