Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 adrianholovaty authored
Showing with 10 additions and 0 deletions.
  1. +6 −0 django/utils/httpwrappers.py
  2. +4 −0 docs/request_response.txt
6 django/utils/httpwrappers.py
View
@@ -175,6 +175,12 @@ def set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=
if val is not None:
self.cookies[key][var.replace('_', '-')] = val
+ def delete_cookie(self, key):
+ try:
+ self.cookies[key]['max_age'] = 0
+ except KeyError:
+ pass
+
def get_content_as_string(self, encoding):
"""
Returns the content as a string, encoding it from a Unicode object if
4 docs/request_response.txt
View
@@ -286,6 +286,10 @@ Methods
.. _`cookie Morsel`: http://www.python.org/doc/current/lib/morsel-objects.html
+``delete_cookie(key)``
+ Deletes the cookie with the given key. Fails silently if the key doesn't
+ exist.
+
``get_content_as_string(encoding)``
Returns the content as a Python string, encoding it from a Unicode object
if necessary.
Please sign in to comment.
Something went wrong with that request. Please try again.