paste.session
– Simple file-based sessions¶
Creates a session object in your WSGI environment.
Use like:
..code-block:: Python
environ[‘paste.session.factory’]()
This will return a dictionary. The contents of this dictionary will be saved to disk when the request is completed. The session will be created when you first fetch the session dictionary, and a cookie will be sent in that case. There’s current no way to use sessions without cookies, and there’s no way to delete a session except to clear its data.
@@: This doesn’t do any locking, and may cause problems when a single session is accessed concurrently. Also, it loads and saves the session for each request, with no caching. Also, sessions aren’t expired.
Module Contents¶
- class paste.session.SessionMiddleware(application, global_conf=None, **factory_kw)¶
- paste.session.make_session_middleware(app, global_conf, session_expiration=<dynamic default>, expiration=<dynamic default>, cookie_name=<dynamic default>, session_file_path=<dynamic default>, chmod=<dynamic default>)¶
Adds a middleware that handles sessions for your applications. The session is a peristent dictionary. To get this dictionary in your application, use
environ['paste.session.factory']()
which returns this persistent dictionary.Configuration:
- session_expiration:
The time each session lives, in minutes. This controls the cookie expiration. Default 12 hours.
- expiration:
The time each session lives on disk. Old sessions are culled from disk based on this. Default 48 hours.
- cookie_name:
The cookie name used to track the session. Use different names to avoid session clashes.
- session_file_path:
Sessions are put in this location, default /tmp.
- chmod:
The octal chmod you want to apply to new sessions (e.g., 660 to make the sessions group readable/writable)
Each of these also takes from the global configuration. cookie_name and chmod take from session_cookie_name and session_chmod