Changes between Version 8 and Version 9 of CookBookDualSessionMiddleware


Ignore:
Timestamp:
10/30/2008 08:02:18 AM (7 years ago)
Author:
shimonrura
Comment:

Adding Django 1.0 session set_expiry comment

Legend:

Unmodified
Added
Removed
Modified
  • CookBookDualSessionMiddleware

    v8 v9  
     1'''Obsoleted by Django 1.0:''' Django 1.0's session object introduced a set_expiry() method, which can be used to set the expiration policy on a per-session basis.  To implement "remember me" functionality, simply configure whatever default session length you prefer in your settings.py, and after user login call request.session.set_expiry with some large number of seconds if the user has checked the "remember me" box.  No extra middleware is needed.
     2
     3See http://docs.djangoproject.com/en/dev/topics/http/sessions/ for detailed session docs.
     4
     5----
     6
    17The default [http://www.djangoproject.com/documentation/sessions/ SessionMiddleware] that comes with Django lets you pick if you want all sessions to be browser-length or persistent, if you want to use different types of sessions based on a users preference (e.g. the good old "Remember Me" check-box) you're gonna have to write your own middleware. Fortunately it's pretty easy, this page documents my attempt, I don't like the "!DualSession" name much, but it's the best I could come up with.
    28
Back to Top