Version 2 (modified by cmlenz, 15 years ago) (diff) |
---|
Session State
The diva.session module implements management of session state, based entirely on client-side storage via HTTP cookies.
Design
Usage
When the session filter is enabled (which is the default), a plain Python dict is made available as the application context variable app.ctxt.session. It should usually not be necessary to access that dictionary directly, as the diva.session module provides a couple of module-level functions to read, write and delete session data.
For example, a simple request handler accessing the session might look like this:
from diva import session from diva.templating import output, render @output('test.html') def test(request, response): cnt = session.get('counter', 0) + 1 session.set('counter', cnt) return render(counter=cnt)
API Documentation