Package cherrypy :: Package lib :: Module sessions
[hide private]
[frames] | no frames]

Module sessions

source code

Session implementation for CherryPy.

We use cherrypy.request to store some convenient variables as well as data about the session for the current request. Instead of polluting cherrypy.request we use a Session object bound to cherrypy.session to store these variables.

Classes [hide private]
  Session
A CherryPy dict-like Session object (one per request).
  RamSession
  FileSession
Implementation of the File backend for sessions
  PostgresqlSession
Implementation of the PostgreSQL backend for sessions.
  MemcachedSession
Functions [hide private]
 
save()
Save any changed session data.
source code
 
close()
Close the session object for this request.
source code
 
init(storage_type='ram', path=None, path_header=None, name='session_id', timeout=60, domain=None, secure=False, clean_freq=5, **kwargs)
Initialize session object (using cookies).
source code
 
set_response_cookie(path=None, path_header=None, name='session_id', timeout=60, domain=None, secure=False)
Set a response cookie for the client.
source code
 
expire()
Expire the current session cookie.
source code
Variables [hide private]
  missing = object()
  __package__ = 'cherrypy.lib'
Function Details [hide private]

init(storage_type='ram', path=None, path_header=None, name='session_id', timeout=60, domain=None, secure=False, clean_freq=5, **kwargs)

source code 
Initialize session object (using cookies).

storage_type: one of 'ram', 'file', 'postgresql'. This will be used
    to look up the corresponding class in cherrypy.lib.sessions
    globals. For example, 'file' will use the FileSession class.
path: the 'path' value to stick in the response cookie metadata.
path_header: if 'path' is None (the default), then the response
    cookie 'path' will be pulled from request.headers[path_header].
name: the name of the cookie.
timeout: the expiration timeout (in minutes) for both the cookie and
    stored session data.
domain: the cookie domain.
secure: if False (the default) the cookie 'secure' value will not
    be set. If True, the cookie 'secure' value will be set (to 1).
clean_freq (minutes): the poll rate for expired session cleanup.

Any additional kwargs will be bound to the new Session instance,
and may be specific to the storage type. See the subclass of Session
you're using for more information.

set_response_cookie(path=None, path_header=None, name='session_id', timeout=60, domain=None, secure=False)

source code 
Set a response cookie for the client.

path: the 'path' value to stick in the response cookie metadata.
path_header: if 'path' is None (the default), then the response
    cookie 'path' will be pulled from request.headers[path_header].
name: the name of the cookie.
timeout: the expiration timeout for the cookie.
domain: the cookie domain.
secure: if False (the default) the cookie 'secure' value will not
    be set. If True, the cookie 'secure' value will be set (to 1).