summaryrefslogtreecommitdiff
path: root/docs/authentication.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-02-10 15:27:36 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-02-10 15:27:36 +0000
commit5c0380b6ede3b8e1d18e8abe40451ba9632202bf (patch)
treeca477abdd489591fef4ec90beb2e9fd9bdf00428 /docs/authentication.txt
parente0c915ec39c646f9444eebf37abca015d7a48865 (diff)
Added 'How to log a user in' section to docs/authetication.txt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/authentication.txt')
-rw-r--r--docs/authentication.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/authentication.txt b/docs/authentication.txt
index b784242f55..fd9da17c8b 100644
--- a/docs/authentication.txt
+++ b/docs/authentication.txt
@@ -228,6 +228,21 @@ information.
.. _request objects: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
.. _session documentation: http://www.djangoproject.com/documentation/sessions/
+How to log a user in
+~~~~~~~~~~~~~~~~~~~~
+
+To log a user in, do the following within a view::
+
+ from django.models.auth import users
+ request.session[users.SESSION_KEY] = some_user.id
+
+Because this uses sessions, you'll need to make sure you have
+``SessionMiddleware`` enabled. See the `session documentation`_ for more
+information.
+
+This assumes ``some_user`` is your ``User`` instance. Depending on your task,
+you'll probably want to make sure to validate the user's username and password.
+
Limiting access to logged-in users
----------------------------------