5.2.6 pse.plugins.session -- persistent, per user session data

The pse.plugins.session module can be used to store information between requests on a per user session basis. This module can be used to keep persistent data available for a specific user using cookies, even after the user has closed the browser and begun a new browsing session.

As with the pse.plugins.application module, session data can be stored in a global namespace or a namespace of your choosing to prevent accidental name collision in different parts of the application or between different applications. Namespace identifiers can be any hashable type for the purpose of dictionary keys. The only restriction is that namespaces cannot begin with the underscore character ("_").

The following values are configurable in the plugins.session section of the pse.conf file:

The chance in 1000 that an access to a session environment will initiate a garbage collection in the session database. Default value: 1
The life of the session cookie since the last page access in minutes. Default value: 360
The psycopg DSN connect string of the database to store the session table. Default: dbname=pse
Note: This is only for the psycopg session type. See File for other session types' parameters.
The path of the file used to store the session database, which must be readable and writable by the apache process. If you want to destroy all user session information, simply delete this file. Note that for dbm sessions, File is actually a directory that holds the database and a Berkeley Database environment subsystem for locking support. Default: /tmp/pse_session
Note: This option is only for the dbm and sqlite session types. See DSN and Table for psycopg parameters.
The name of the table that stores the session data. Default: pse_session
Note: This is only for the psycopg session type. See File for other session types' parameters.
The minimum length of time a session will be stored, in minutes, in the database before being garbage collected. Default: 360
The type of session back-end to use, which can be one of dbm, sqlite or psycopg. Default: dbm

New in version 3.0.

Data can be stored either in a BSD-style DBM hash file, an SQLite database or a PostgreSQL database. The BSD-style DBM session type requires the bsddb module, which builds by default with Python. The SQLite session type requires at least version 3 of the SQLite libraries and version 2 of Python module (pysqlite2). The psycopg (PostgreSQL) type requires the psycopg module, available from http://initd.org/software/initd/psycopg. Whichever module is used, all have the same interface as follows:

new( [namespace])
Return a new session namespace dictionary. If namespace is specified, a persistent dictionary is returned. If the namespace has already previously been created, then that same dictionary will be returned, otherwise an empty dictionary will be returned.

If namespace is omitted, then the global session namespace will be returned.

delete( namespace)
Delete the specified namespace. If the namespace did not previously exist, then the delete function will silently do nothing. You cannot delete the global namespace -- use del on individual elements in the dictionary instead.