class documentation

class SessionBase:

Known subclasses: django.contrib.sessions.backends.db.SessionStore, django.contrib.sessions.backends.cache.SessionStore, django.contrib.sessions.backends.file.SessionStore, django.contrib.sessions.backends.signed_cookies.SessionStore

View In Hierarchy

Base class for all Session classes.
Class Method clear​_expired Remove expired sessions from the session store.
Method __contains__ Undocumented
Method __delitem__ Undocumented
Method __getitem__ Undocumented
Method __setitem__ Undocumented
Method clear Undocumented
Method cycle​_key Create a new session key, while retaining the current session data.
Method delete​_test​_cookie Undocumented
Method flush Remove the current session data from the database and regenerate the key.
Method get Undocumented
Method get​_expire​_at​_browser​_close No summary
Method get​_expiry​_age Get the number of seconds until the session expires.
Method get​_expiry​_date Get session the expiry date (as a datetime object).
Method get​_session​_cookie​_age Undocumented
Method items Undocumented
Method keys Undocumented
Method pop Undocumented
Method set​_expiry Set a custom expiration for the session. value can be an integer, a Python datetime or timedelta object or None.
Method set​_test​_cookie Undocumented
Method setdefault Undocumented
Method test​_cookie​_worked Undocumented
Constant TEST​_COOKIE​_NAME Undocumented
Constant TEST​_COOKIE​_VALUE Undocumented
Method __init__ Undocumented
Method ​_get​_new​_session​_key Return session key that isn't being used.
Method ​_get​_or​_create​_session​_key Undocumented
Method ​_get​_session Lazily load session from storage (unless "no_load" is True, when only an empty dict is stored) and store it in the current instance.
Method ​_get​_session​_key Undocumented
Method ​_set​_session​_key Validate session key on assignment. Invalid values will set to None.
Method ​_validate​_session​_key Key must be truthy and at least 8 characters long. 8 characters is an arbitrary lower bound for some minimal key security.
Method create Create a new session instance. Guaranteed to create a new object with a unique key and will have saved the result once (with empty data) before the method returns.
Method decode Undocumented
Method delete Delete the session data under this key. If the key is None, use the current session key value.
Method encode Return the given session dictionary serialized and encoded as a string.
Method exists Return True if the given session_key already exists.
Method has​_key Undocumented
Method is​_empty Return True when there is no session_key and the session is empty.
Method load Load the session data and return a dictionary.
Method save Save the session data. If 'must_create' is True, create a new session object (or raise CreateError). Otherwise, only update an existing object and don't create one (raise UpdateError if needed).
Method update Undocumented
Method values Undocumented
Class Variable __not​_given Undocumented
Class Variable ​_session Undocumented
Class Variable session​_key Undocumented
Instance Variable __session​_key Undocumented
Instance Variable ​_session​_cache Undocumented
Instance Variable ​_session​_key Undocumented
Instance Variable accessed Undocumented
Instance Variable modified Undocumented
Instance Variable serializer Undocumented
Property key​_salt Undocumented
@classmethod
def clear_expired(cls):

Remove expired sessions from the session store.

If this operation isn't possible on a given backend, it should raise NotImplementedError. If it isn't necessary, because the backend has a built-in expiration mechanism, it should be a no-op.

def __contains__(self, key):

Undocumented

def __delitem__(self, key):

Undocumented

def __getitem__(self, key):

Undocumented

def __setitem__(self, key, value):

Undocumented

def clear(self):

Undocumented

def cycle_key(self):
Create a new session key, while retaining the current session data.
def delete_test_cookie(self):

Undocumented

def flush(self):
Remove the current session data from the database and regenerate the key.
def get(self, key, default=None):

Undocumented

def get_expire_at_browser_close(self):
Return True if the session is set to expire when the browser closes, and False if there's an expiry date. Use get_expiry_date() or get_expiry_age() to find the actual expiry date/age, if there is one.
def get_expiry_age(self, **kwargs):

Get the number of seconds until the session expires.

Optionally, this function accepts modification and expiry keyword arguments specifying the modification and expiry of the session.

def get_expiry_date(self, **kwargs):

Get session the expiry date (as a datetime object).

Optionally, this function accepts modification and expiry keyword arguments specifying the modification and expiry of the session.

def get_session_cookie_age(self):

Undocumented

def items(self):

Undocumented

def keys(self):

Undocumented

def pop(self, key, default=__not_given):

Undocumented

def set_expiry(self, value):

Set a custom expiration for the session. value can be an integer, a Python datetime or timedelta object or None.

If value is an integer, the session will expire after that many seconds of inactivity. If set to 0 then the session will expire on browser close.

If value is a datetime or timedelta object, the session will expire at that specific future time.

If value is None, the session uses the global session expiry policy.

def set_test_cookie(self):

Undocumented

def setdefault(self, key, value):

Undocumented

def test_cookie_worked(self):

Undocumented

TEST_COOKIE_NAME: str =

Undocumented

Value
'testcookie'
TEST_COOKIE_VALUE: str =

Undocumented

Value
'worked'
def _get_new_session_key(self):
Return session key that isn't being used.
def _get_or_create_session_key(self):

Undocumented

def _get_session(self, no_load=False):
Lazily load session from storage (unless "no_load" is True, when only an empty dict is stored) and store it in the current instance.
def _get_session_key(self):
def _set_session_key(self, value):
Validate session key on assignment. Invalid values will set to None.
def _validate_session_key(self, key):
Key must be truthy and at least 8 characters long. 8 characters is an arbitrary lower bound for some minimal key security.
def create(self):
Create a new session instance. Guaranteed to create a new object with a unique key and will have saved the result once (with empty data) before the method returns.
def decode(self, session_data):

Undocumented

def delete(self, session_key=None):
def encode(self, session_dict):
Return the given session dictionary serialized and encoded as a string.
def has_key(self, key):

Undocumented

def is_empty(self):
Return True when there is no session_key and the session is empty.
def save(self, must_create=False):
Save the session data. If 'must_create' is True, create a new session object (or raise CreateError). Otherwise, only update an existing object and don't create one (raise UpdateError if needed).
def update(self, dict_):

Undocumented

def values(self):

Undocumented

__not_given =

Undocumented

_session =

Undocumented

session_key =

Undocumented

__session_key =

Undocumented

_session_cache =
accessed: bool =

Undocumented

serializer =

Undocumented

@property
key_salt =

Undocumented