From b448593432089eef7a795a7f91dc4f55c7407aeb Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 15 Sep 2007 22:36:53 +0000 Subject: [PATCH] Edited docs/sessions.txt changes from [6333] git-svn-id: http://code.djangoproject.com/svn/django/trunk@6344 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/sessions.txt | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/sessions.txt b/docs/sessions.txt index 023285f704d..ab7ea56aaa6 100644 --- a/docs/sessions.txt +++ b/docs/sessions.txt @@ -18,13 +18,13 @@ To enable session functionality, do the following: ``MIDDLEWARE_CLASSES`` contains ``'django.contrib.sessions.middleware.SessionMiddleware'``. The default ``settings.py`` created by ``django-admin.py startproject`` has ``SessionMiddleware`` activated. - + * Add ``'django.contrib.sessions'`` to your ``INSTALLED_APPS`` setting, and run ``manage.py syncdb`` to install the single database table that stores session data. - + **New in development version**: this step is optional if you're not using - the database session backend; see `configuring the session engine`_. + the database session backend; see `configuring the session engine`_. If you don't want to use sessions, you might as well remove the ``SessionMiddleware`` line from ``MIDDLEWARE_CLASSES`` and ``'django.contrib.sessions'`` @@ -50,7 +50,7 @@ To use file-based sessions, set the ``SESSION_ENGINE`` setting to You might also want to set the ``SESSION_FILE_PATH`` setting (which defaults to ``/tmp``) to control where Django stores session files. Be -sure to check that your web server has permissions to read and write to +sure to check that your Web server has permissions to read and write to this location. Using cache-based sessions @@ -64,8 +64,8 @@ you've configured your cache; see the `cache documentation`_ for details. .. note:: - You probably don't want to use cache-based sessions if you're not using - the memcached cache backend. The local memory and simple cache backends + You should probably only use cache-based sessions if you're using the + memcached cache backend. The local memory and simple cache backends don't retain data long enough to be good choices, and it'll be faster to use file or database sessions directly instead of sending everything through the file or database cache backends. @@ -194,8 +194,9 @@ Here's a typical usage example:: Using sessions out of views =========================== -The ``SessionStore`` which implements the session storage method can be imported -and a API is available to manipulate the session data outside of a view:: +**New in Django development version** + +An API is available to manipulate session data outside of a view:: >>> from django.contrib.sessions.engines.db import SessionStore >>> s = SessionStore(session_key='2b1189a188b44ad18c35e113ac6ceead') @@ -204,15 +205,15 @@ and a API is available to manipulate the session data outside of a view:: datetime.datetime(2005, 8, 20, 13, 35, 0) >>> s.save() -Or if you are using the ``django.contrib.sessions.engine.db`` each -session is just a normal Django model. The ``Session`` model -is defined in ``django/contrib/sessions/models.py``. Because it's a normal -model, you can access sessions using the normal Django database API:: +If you're using the ``django.contrib.sessions.engine.db`` backend, each +session is just a normal Django model. The ``Session`` model is defined in +``django/contrib/sessions/models.py``. Because it's a normal model, you can +access sessions using the normal Django database API:: >>> from django.contrib.sessions.models import Session >>> s = Session.objects.get(pk='2b1189a188b44ad18c35e113ac6ceead') >>> s.expire_date - datetime.datetime(2005, 8, 20, 13, 35, 12) + datetime.datetime(2005, 8, 20, 13, 35, 12) Note that you'll need to call ``get_decoded()`` to get the session dictionary. This is necessary because the dictionary is stored in an encoded format:: @@ -306,10 +307,10 @@ Default: ``django.contrib.sessions.backends.db`` Controls where Django stores session data. Valid values are: - * ``'django.contrib.sessions.backends.db'`` - * ``'django.contrib.sessions.backends.file'`` + * ``'django.contrib.sessions.backends.db'`` + * ``'django.contrib.sessions.backends.file'`` * ``'django.contrib.sessions.backends.cache'`` - + See `configuring the session engine`_ for more details. SESSION_FILE_PATH