Ticket #6657: set_cookie.diff

File set_cookie.diff, 1.3 KB (added by Marty Alchin, 17 years ago)

Changed set_cookie() to take secure=False and to only set it on the cookie if it evaluates to True

  • django/http/__init__.py

     
    314314    def get(self, header, alternate):
    315315        return self._headers.get(header.lower(), (None, alternate))[1]
    316316
    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):
    318318        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
    323329
    324330    def delete_cookie(self, key, path='/', domain=None):
    325331        self.set_cookie(key, max_age=0, path=path, domain=domain,
Back to Top