The SessionManager
object is aliased as web.session.manager
and should be used as web.session.manager
.
driver, [expire=86400], [cookie], [autoCreate=0], [_seed], [_cleanupProbability], [**driverParams]) |
Used to return a session manager object.
Manager Parameters:
driver
can be a Driver
object as returned by web.session.driver() and no **driverParams need to be specified.
web.session.cookieDefaults
.
In particular you may wish to modify the following parameters:
path
'/'
which means the whole website. XXX is this correct?
domain
''
which means any domain. XXX is this correct?
comment
max-age
0
the cookie will expire immediately. If not present the cookie will take the expire time of the session. If set to None
the cookie will last until the web browser is closed.
By default the max-age
of the cookie is set to be the same as the expire time set by the expire parameter.
True
the necessary tables will be created (removing any existing tables) if any of the tables are missing. This is designed for easy testing of the module.
'PythonWeb'
.
1
cleanup is done every time a manager is created. If _cleanupProbability is 0
no automatic cleanup is done and cleanup is left to the administrator. The default is 0.05
which means old session information is removed roughly every 20 times a manager object is created.
All session manager objects have the read only member variables which you should not set:
None
before that time.
None
.
(type, value)
) |
True
if the environment is correctly setup, False
otherwise. In the case of the database driver this method simply checks that all the necessary tables exist.
) |
SessionError
is raised.
[ignoreErrors=False]) |
SessionError
is raised unless ignoreErrors is True
.
[sessionID=None]) |
os.environ
. If your environment doesn't support loading of a cookie in this way seesionID should be specified.
If the session exists and is valid it is loaded and the method returns True
otherwise it returns False
and you should create a new session using create(). The reason the session could not be loaded is set to the error
attribute.
[sendCookieHeaders=True], [expire]) |
SessionError
is raised. self._seed
is specified it is used to make the generation of session ID more random.
If sendCookieHeaders is True
a Set-Cookie
HTTP header is immediately printed. If False
a WSGI (type, info)
header is appended to response_headers
so the application can handle the header itself. If expire is the number of seconds the session should be valid for. If not specified the value of the expire
attribute is used. Returns the new session ID.
app) |
a-z
, A-Z
, 0-9
and -_.
. The application name must be between 1 and 255 characters in length. The application names do not have to be the same as application names used by the web.auth module, although these are the most appropriate choices. If you are not using multiple applications you should still give your application a name, perhaps 'default'
for example.
[sessionID], [sendCookieHeaders=True], [ignoreWarning=False]) |
True
a Set-Cookie
HTTP header is immediately printed. If False
a WSGI (type, info)
header is appended to response_headers
so the application can handle the header itself. If ignoreWarning is not set to True
a SessionWarning
is raised explaining why destroying sessions is not a good idea.
Warning:
Destroying sessions is strongly not recommended since any other application currently using the session store may crash as the session information will have been removed. If you wish to remove all data from the session store it would be better to use the store object's empty() method, emptying the store but leaving the session intact. If you must remove a session use setExpire(time.time())
to make the session expire immediately or send a cookie built with _deleteCookieString(). Any applications using the session will still be able to access the information if they have already loaded the session but will not be able to load the session again.
[environ=None], [noSessionID='']) |
HTTP_COOKIE
environmental variable. The default environ
dictionary is os.environ
. If you wish to provide your own environment dictionary (for example you are using a WSGI application) you can specify environ. If the session ID cannot be loaded noSessionID is returned which by default is an empty string.
[min], [max], [ignoreWarning=False]) |
0
(the beginning of the epoch), if max is not specified it is assumed to be the current time. If you specify a value max greater than the current time returned bt time.time()
a SessionWarning
is raised. To ignore the warning set ignoreWarning to True
.
Warning: You should not set a value of max greater than the current time unless you understand the risk since doing so will remove sessions which haven't yet expired. If an application is using the session store and its session is cleaned up, that application may crash.
expireTime, [sessionID]) |
[sessionID]) |
True
if the session is valid, False
if the session has expired. A SessionError
is raised if the session does not exist. Whether or not a session exists can be checked with the exists() method.
[sessionID]) |
True
if the session is exists, False
if the session does not exist. No comment is made on whether or not the session is still valid, instead this can be checked with the valid() method.
) |
print
statement to send any headers in the response_headers
attribute to the standard output, appending the exact strings printed to the send_headers
attribute for debugging purposes. Used by the create() and destroy() methods to send cookie headers so could be over-ridden in derived classes to change cookie handling behaviour.
[sendCookieHeaders=False], [_cookieString=None]) |
(type, info)
pair and append it to the response_headers
attribute. If sendCookieHeaders is True
, sendCookieHeaders() is called to send the cookie header. _cookieString can be used to specify the cookie to set, if None
the cookie string is automatically generated.
[maxAge]) |
[sendCookieHeaders=False]) |
(type, info)
pair and append it to the response_headers
attribute. If sendCookieHeaders is True
, sendCookieHeaders() is called to send the cookie header.
) |