Django

Code

Changeset 3545

Show
Ignore:
Timestamp:
08/09/06 10:40:24 (2 years ago)
Author:
adrian
Message:

Fixed #2503 -- Fixed HttpResponse.delete_cookie() to work properly. It now takes path and domain as optional keyword arguments.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/http/__init__.py

    r3410 r3545  
    3939    def get_full_path(self): 
    4040        return '' 
    41          
     41 
    4242    def is_secure(self): 
    4343        return os.environ.get("HTTPS") == "on" 
     
    204204                self.cookies[key][var.replace('_', '-')] = val 
    205205 
    206     def delete_cookie(self, key): 
    207         try: 
    208             self.cookies[key]['max_age'] = 0 
    209         except KeyError: 
    210             pass 
     206    def delete_cookie(self, key, path='/', domain=None): 
     207        self.cookies[key] = '' 
     208        if path is not None: 
     209            self.cookies[key]['path'] = path 
     210        if domain is not None: 
     211            self.cookies[key]['domain'] = path 
     212        self.cookies[key]['expires'] = 0 
     213        self.cookies[key]['max-age'] = 0 
    211214 
    212215    def _get_content(self): 
  • django/trunk/docs/request_response.txt

    r3410 r3545  
    150150 
    151151   Example: ``"/music/bands/the_beatles/?print=true"`` 
    152      
     152 
    153153``is_secure()`` 
    154154   Returns ``True`` if the request is secure; that is, if it was made with 
     
    381381    .. _`cookie Morsel`: http://www.python.org/doc/current/lib/morsel-objects.html 
    382382 
    383 ``delete_cookie(key)`` 
     383``delete_cookie(key, path='/', domain=None)`` 
    384384    Deletes the cookie with the given key. Fails silently if the key doesn't 
    385385    exist. 
     386 
     387    The ``path`` and ``domain`` arguments are new in the Django development version. 
     388    Due to the way cookies work, ``path`` and ``domain`` should be the same 
     389    values you used in ``set_cookie()`` -- otherwise the cookie may not be deleted. 
    386390 
    387391``content``