SecureCookieSessionInterface
The default session interface that stores sessions in signed cookies through the :mod:itsdangerous module.
Attributes
| Attribute | Type | Description |
|---|---|---|
| salt | = cookie-session | The salt that should be applied on top of the secret key for the signing of cookie based sessions. |
| digest_method | = staticmethod(_lazy_sha1) | The hash function to use for the signature, defaulting to sha1. |
| key_derivation | = hmac | The name of the itsdangerous supported key derivation, defaulting to hmac. |
| serializer | = session_json_serializer | A Python serializer for the payload, defaulting to a compact JSON derived serializer with support for extra Python types. |
| session_class | = SecureCookieSession | The class used to represent the session, which is SecureCookieSession. |
Methods
get_signing_serializer()
@classmethod
def get_signing_serializer(
app: [Flask](../app/flask.md?sid=flask_app_flask)
) - > URLSafeTimedSerializer | None
Retrieves the signing serializer for the application. This serializer is used to sign and unsign session cookies, ensuring their integrity and authenticity.
Parameters
| Name | Type | Description |
|---|---|---|
| app | [Flask](../app/flask.md?sid=flask_app_flask) | The Flask application instance, used to access configuration like the secret key. |
Returns
| Type | Description |
|---|---|
| `URLSafeTimedSerializer | None` |
open_session()
@classmethod
def open_session(
app: [Flask](../app/flask.md?sid=flask_app_flask),
request: [Request](../wrappers/request.md?sid=flask_wrappers_request)
) - > SecureCookieSession | None
Opens and loads a session from the incoming request's cookies. It deserializes the session data using the signing serializer and returns a SecureCookieSession object.
Parameters
| Name | Type | Description |
|---|---|---|
| app | [Flask](../app/flask.md?sid=flask_app_flask) | The Flask application instance, used to retrieve the signing serializer and cookie name. |
| request | [Request](../wrappers/request.md?sid=flask_wrappers_request) | The incoming request object, from which the session cookie is read. |
Returns
| Type | Description |
|---|---|
| `SecureCookieSession | None` |
save_session()
@classmethod
def save_session(
app: [Flask](../app/flask.md?sid=flask_app_flask),
session: [SessionMixin](sessionmixin.md?sid=flask_sessions_sessionmixin),
response: [Response](../wrappers/response.md?sid=flask_wrappers_response)
) - > None
Saves the current session to the outgoing response's cookies. It serializes the session data, signs it, and sets the appropriate cookie headers on the response.
Parameters
| Name | Type | Description |
|---|---|---|
| app | [Flask](../app/flask.md?sid=flask_app_flask) | The Flask application instance, used to retrieve cookie configuration and the signing serializer. |
| session | [SessionMixin](sessionmixin.md?sid=flask_sessions_sessionmixin) | The session object to be saved. If the session is empty and modified, its cookie will be deleted. |
| response | [Response](../wrappers/response.md?sid=flask_wrappers_response) | The outgoing response object, where the session cookie will be set or deleted. |
Returns
| Type | Description |
|---|---|
None | This method does not return any value; it modifies the response object by setting or deleting a cookie. |