summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-09-23 01:28:44 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-09-23 01:28:44 +0000
commit39a907a051617d97a9724512791a4d9a53ee2f10 (patch)
treeff5a2784b312c3a5dd2c8fec3f4961c6d0e80b6e /docs
parent3dc1ede8718056cf107abf06f6f213cbe23374c8 (diff)
Added request.session.delete_test_cookie()
git-svn-id: http://code.djangoproject.com/svn/django/trunk@669 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/sessions.txt9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/sessions.txt b/docs/sessions.txt
index ad715767ca..22d06fdedd 100644
--- a/docs/sessions.txt
+++ b/docs/sessions.txt
@@ -46,7 +46,7 @@ It implements the following standard dictionary methods:
* ``get(key, default=None)``
Example: ``fav_color = request.session.get('fav_color', 'red')``
-It also has these two methods:
+It also has these three methods:
* ``set_test_cookie()``
Sets a test cookie to determine whether the user's browser supports
@@ -60,6 +60,9 @@ It also has these two methods:
have to call ``set_test_cookie()`` on a previous, separate page request.
See "Setting test cookies" below for more information.
+ * ``delete_test_cookie()``
+ Deletes the test cookie. Use this to clean up after yourself.
+
You can edit ``request.session`` at any point in your view. You can edit it
multiple times.
@@ -120,11 +123,15 @@ This awkward split between ``set_test_cookie()`` and ``test_cookie_worked()``
is necessary due to the way cookies work. When you set a cookie, you can't
actually tell whether a browser accepted it until the browser's next request.
+It's good practice to use ``delete_test_cookie()`` to clean up after yourself.
+Do this after you've verified that the test cookie worked.
+
Here's a typical usage example::
def login(request):
if request.POST:
if request.session.test_cookie_worked():
+ request.session.delete_test_cookie()
return HttpResponse("You're logged in.")
else:
return HttpResponse("Please enable cookies and try again.")