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
| Attribute | Type | Description |
|---|---|---|
| session_key | string | Unique identifier for the session used as the primary key with a maximum length of 40 characters. |
| session_data | string | Encoded string containing the serialized session dictionary data. |
| expire_date | datetime | The 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
| Name | Type | Description |
|---|---|---|
| *args | any | Positional arguments passed to the parent model constructor. |
| **kwargs | any | Keyword 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
| Type | Description |
|---|---|
class | The 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
| Type | Description |
|---|---|
dict | The decoded session data containing the stored session variables. |