Skip to main content

AbstractBaseSession

This abstract base class provides the foundational schema and logic for managing session data in a database. It defines essential fields for session keys, encoded data, and expiration timestamps, while requiring subclasses to implement a specific session store class. The class also includes a utility method to decode session data using the associated store implementation.

Attributes

AttributeTypeDescription
session_keystringUnique identifier for the session used as the primary key with a maximum length of 40 characters.
session_datastringEncoded string containing the serialized session dictionary data.
expire_datedatetimeThe date and time when the session becomes invalid, indexed for efficient expiration lookups.
objects[BaseSessionManager](basesessionmanager.md?sid=django_contrib_sessions_base_session_basesessionmanager)The manager instance providing database query operations for session models.

Constructor

Signature

def AbstractBaseSession(
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*argsanyPositional arguments passed to the parent model constructor.
**kwargsanyKeyword arguments representing model fields such as session_key, session_data, and expire_date.

Methods


get_session_store_class()

@classmethod
def get_session_store_class() - > class

Returns the session store class that should be used with this session model.

Returns

TypeDescription
classThe class type used for managing session storage and operations.

get_decoded()

@classmethod
def get_decoded() - > dict

Decodes the raw session data string into a dictionary-like object.

Returns

TypeDescription
dictThe decoded session data containing the stored session variables.