Skip to content

Commit

Permalink
Added 'How to log a user in' section to docs/authetication.txt
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Feb 10, 2006
1 parent e0c915e commit 5c0380b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/authentication.txt
Expand Up @@ -228,6 +228,21 @@ information.
.. _request objects: http://www.djangoproject.com/documentation/request_response/#httprequest-objects .. _request objects: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
.. _session documentation: http://www.djangoproject.com/documentation/sessions/ .. _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 Limiting access to logged-in users
---------------------------------- ----------------------------------


Expand Down

0 comments on commit 5c0380b

Please sign in to comment.