Changeset 669
- Timestamp:
- 09/22/05 20:28:44 (3 years ago)
- Files:
-
- django/trunk/django/middleware/admin.py (modified) (1 diff)
- django/trunk/django/middleware/sessions.py (modified) (1 diff)
- django/trunk/django/views/auth/login.py (modified) (1 diff)
- django/trunk/docs/sessions.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/middleware/admin.py
r529 r669 82 82 return 83 83 else: 84 request.session.delete_test_cookie() 84 85 return httpwrappers.HttpResponseRedirect(request.path) 85 86 else: django/trunk/django/middleware/sessions.py
r667 r669 30 30 def test_cookie_worked(self): 31 31 return self.get(TEST_COOKIE_NAME) == TEST_COOKIE_VALUE 32 33 def delete_test_cookie(self): 34 del self[TEST_COOKIE_NAME] 32 35 33 36 def _get_session(self): django/trunk/django/views/auth/login.py
r665 r669 19 19 redirect_to = '/accounts/profile/' 20 20 request.session[users.SESSION_KEY] = manipulator.get_user_id() 21 request.session.delete_test_cookie() 21 22 return HttpResponseRedirect(redirect_to) 22 23 else: django/trunk/docs/sessions.txt
r524 r669 47 47 Example: ``fav_color = request.session.get('fav_color', 'red')`` 48 48 49 It also has these t womethods:49 It also has these three methods: 50 50 51 51 * ``set_test_cookie()`` … … 60 60 have to call ``set_test_cookie()`` on a previous, separate page request. 61 61 See "Setting test cookies" below for more information. 62 63 * ``delete_test_cookie()`` 64 Deletes the test cookie. Use this to clean up after yourself. 62 65 63 66 You can edit ``request.session`` at any point in your view. You can edit it … … 121 124 actually tell whether a browser accepted it until the browser's next request. 122 125 126 It's good practice to use ``delete_test_cookie()`` to clean up after yourself. 127 Do this after you've verified that the test cookie worked. 128 123 129 Here's a typical usage example:: 124 130 … … 126 132 if request.POST: 127 133 if request.session.test_cookie_worked(): 134 request.session.delete_test_cookie() 128 135 return HttpResponse("You're logged in.") 129 136 else:
