Changeset 6344
- Timestamp:
- 09/15/07 17:36:53 (1 year ago)
- Files:
-
- django/trunk/docs/sessions.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/sessions.txt
r6333 r6344 19 19 The default ``settings.py`` created by ``django-admin.py startproject`` has 20 20 ``SessionMiddleware`` activated. 21 21 22 22 * Add ``'django.contrib.sessions'`` to your ``INSTALLED_APPS`` setting, 23 23 and run ``manage.py syncdb`` to install the single database table 24 24 that stores session data. 25 25 26 26 **New in development version**: this step is optional if you're not using 27 the database session backend; see `configuring the session engine`_. 27 the database session backend; see `configuring the session engine`_. 28 28 29 29 If you don't want to use sessions, you might as well remove the … … 51 51 You might also want to set the ``SESSION_FILE_PATH`` setting (which 52 52 defaults to ``/tmp``) to control where Django stores session files. Be 53 sure to check that your web server has permissions to read and write to53 sure to check that your Web server has permissions to read and write to 54 54 this location. 55 55 … … 65 65 .. note:: 66 66 67 You probably don't want to use cache-based sessions if you're not using68 thememcached cache backend. The local memory and simple cache backends67 You should probably only use cache-based sessions if you're using the 68 memcached cache backend. The local memory and simple cache backends 69 69 don't retain data long enough to be good choices, and it'll be faster 70 70 to use file or database sessions directly instead of sending everything … … 195 195 =========================== 196 196 197 The ``SessionStore`` which implements the session storage method can be imported 198 and a API is available to manipulate the session data outside of a view:: 197 **New in Django development version** 198 199 An API is available to manipulate session data outside of a view:: 199 200 200 201 >>> from django.contrib.sessions.engines.db import SessionStore … … 205 206 >>> s.save() 206 207 207 Or if you are using the ``django.contrib.sessions.engine.db`` each 208 session is just a normal Django model. The ``Session`` model 209 is defined in ``django/contrib/sessions/models.py``. Because it's a normal 210 model, you canaccess sessions using the normal Django database API::208 If you're using the ``django.contrib.sessions.engine.db`` backend, each 209 session is just a normal Django model. The ``Session`` model is defined in 210 ``django/contrib/sessions/models.py``. Because it's a normal model, you can 211 access sessions using the normal Django database API:: 211 212 212 213 >>> from django.contrib.sessions.models import Session 213 214 >>> s = Session.objects.get(pk='2b1189a188b44ad18c35e113ac6ceead') 214 215 >>> s.expire_date 215 datetime.datetime(2005, 8, 20, 13, 35, 12) 216 datetime.datetime(2005, 8, 20, 13, 35, 12) 216 217 217 218 Note that you'll need to call ``get_decoded()`` to get the session dictionary. … … 307 308 Controls where Django stores session data. Valid values are: 308 309 309 * ``'django.contrib.sessions.backends.db'`` 310 * ``'django.contrib.sessions.backends.file'`` 310 * ``'django.contrib.sessions.backends.db'`` 311 * ``'django.contrib.sessions.backends.file'`` 311 312 * ``'django.contrib.sessions.backends.cache'`` 312 313 313 314 See `configuring the session engine`_ for more details. 314 315
