watson.http.sessions.abc¶
-
class
watson.http.sessions.abc.
StorageMixin
(id=None, timeout=None, autosave=True)[source]¶ The base mixin for all session storage adapters.
By default, if no id is specified when the session is created a new session id will be generated. When a user is logged in, it is good practice to regenerate the id of the session id to prevent session hijacking.
If autosave is set to True, then when data is added to the session the save() method will be called. If set to False, the developer will be required to manually call the save() method themselves.
To function correctly sessions require that cookies are enabled in the users browser.
Example:
session = SessionStorageMethod() # where SessionStorageMethod is a valid storage class session['key'] = 'some value' session['key'] # 'some value'
-
__init__
(id=None, timeout=None, autosave=True)[source]¶ Parameters: - id – the id of the session
- timeout – the expiry time from the current time in seconds
- key – the key used to reference the session id in a cookie
- autosave – save the contents on __setitem__
The cookie params used when saving the session id as a cookie.
-
data
¶ The data associated with the session.
-
exists
()[source]¶ Determine whether or not the session exists in storage.
Returns: Boolean whether or not the session id exists.
-
id
¶ The id of the session.
-
-
watson.http.sessions.abc.
random
() → x in the interval [0, 1).¶