Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #236 -- Added HttpResponse.delete_cookie() method.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@668 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3dc1ede8718056cf107abf06f6f213cbe23374c8 1 parent 8df0df6
Adrian Holovaty authored September 23, 2005
6  django/utils/httpwrappers.py
@@ -175,6 +175,12 @@ def set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=
175 175
             if val is not None:
176 176
                 self.cookies[key][var.replace('_', '-')] = val
177 177
 
  178
+    def delete_cookie(self, key):
  179
+        try:
  180
+            self.cookies[key]['max_age'] = 0
  181
+        except KeyError:
  182
+            pass
  183
+
178 184
     def get_content_as_string(self, encoding):
179 185
         """
180 186
         Returns the content as a string, encoding it from a Unicode object if
4  docs/request_response.txt
@@ -286,6 +286,10 @@ Methods
286 286
 
287 287
     .. _`cookie Morsel`: http://www.python.org/doc/current/lib/morsel-objects.html
288 288
 
  289
+``delete_cookie(key)``
  290
+    Deletes the cookie with the given key. Fails silently if the key doesn't
  291
+    exist.
  292
+
289 293
 ``get_content_as_string(encoding)``
290 294
     Returns the content as a Python string, encoding it from a Unicode object
291 295
     if necessary.

0 notes on commit 3dc1ede

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