sessions.base_session.AbstractBaseSession

class base_session.AbstractBaseSession New in Django 1.9. The abstract base session model. session_key Primary key. The field itself may contain up to 40 characters. The current implementation generates a 32-character string (a random sequence of digits and lowercase ASCII letters). session_data A string containing an encoded and serialized session dictionary. expire_date A datetime designating when the session expires. Expired sessions are not available to a user, however,

sessions.backends.base.SessionBase.__setitem__()

__setitem__(key, value) Example: request.session['fav_color'] = 'blue'

sessions.backends.db.SessionStore

class backends.db.SessionStore Implements database-backed session store. classmethod get_model_class() New in Django 1.9. Override this method to return a custom session model if you need one. create_model_instance(data) New in Django 1.9. Returns a new instance of the session model object, which represents the current session state. Overriding this method provides the ability to modify session model data before it’s saved to database.

sessions.backends.cached_db.SessionStore

class backends.cached_db.SessionStore Implements cached database-backed session store. cache_key_prefix New in Django 1.9. A prefix added to a session key to build a cache key string.

sessions.backends.db.SessionStore.create_model_instance()

create_model_instance(data) New in Django 1.9. Returns a new instance of the session model object, which represents the current session state. Overriding this method provides the ability to modify session model data before it’s saved to database.

sessions.backends.cached_db.SessionStore.cache_key_prefix

cache_key_prefix New in Django 1.9. A prefix added to a session key to build a cache key string.

sessions.backends.base.SessionBase.__getitem__()

__getitem__(key) Example: fav_color = request.session['fav_color']

sessions.backends.base.SessionBase.test_cookie_worked()

test_cookie_worked() Returns either True or False, depending on whether the user’s browser accepted the test cookie. Due to the way cookies work, you’ll have to call set_test_cookie() on a previous, separate page request. See Setting test cookies below for more information.

sessions.backends.base.SessionBase.pop()

pop(key, default=__not_given) Example: fav_color = request.session.pop('fav_color', 'blue')

sessions.backends.base.SessionBase.__delitem__()

__delitem__(key) Example: del request.session['fav_color']. This raises KeyError if the given key isn’t already in the session.