quart.sessions module
- class quart.sessions.SessionInterface
Bases:
object
Base class for session interfaces.
- null_session_class
Storage class for null (no storage) sessions.
- pickle_based
Indicates if pickling is used for the session.
- null_session_class
alias of
NullSession
- pickle_based = False
- async make_null_session(app)
Create a Null session object.
This is used in replacement of an actual session if sessions are not configured or active.
- Parameters:
app (Quart)
- Return type:
NullSession
- is_null_session(instance)
Returns True is the instance is a null session.
- Parameters:
instance (object)
- Return type:
bool
- get_cookie_name(app)
Helper method to return the Cookie Name for the App.
- Parameters:
app (Quart)
- Return type:
str
- get_cookie_domain(app)
Helper method to return the Cookie Domain for the App.
- Parameters:
app (Quart)
- Return type:
str | None
- get_cookie_path(app)
Helper method to return the Cookie path for the App.
- Parameters:
app (Quart)
- Return type:
str
- get_cookie_httponly(app)
Helper method to return if the Cookie should be HTTPOnly for the App.
- Parameters:
app (Quart)
- Return type:
bool
- get_cookie_secure(app)
Helper method to return if the Cookie should be Secure for the App.
- Parameters:
app (Quart)
- Return type:
bool
- get_cookie_samesite(app)
Helper method to return the Cookie Samesite configuration for the App.
- Parameters:
app (Quart)
- Return type:
str
- get_expiration_time(app, session)
Helper method to return the Session expiration time.
If the session is not ‘permanent’ it will expire as and when the browser stops accessing the app.
- Parameters:
app (Quart)
session (SessionMixin)
- Return type:
datetime | None
- should_set_cookie(app, session)
Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app is configured to always refresh the cookie.
- Parameters:
app (Quart)
session (SessionMixin)
- Return type:
bool
- async open_session(app, request)
Open an existing session from the request or create one.
- Returns:
The Session object or None if no session can be created, in which case the
null_session_class
is expected to be used.- Parameters:
app (Quart)
request (BaseRequestWebsocket)
- Return type:
SessionMixin | None
- async save_session(app, session, response)
Save the session argument to the response.
- class quart.sessions.SecureCookieSessionInterface
Bases:
SessionInterface
A Session interface that uses cookies as storage.
This will store the data on the cookie in plain text, but with a signature to prevent modification.
- static digest_method(string=b'', *, usedforsecurity=True)
Returns a sha1 hash object; optionally initialized with a string
- key_derivation = 'hmac'
- salt = 'cookie-session'
- serializer = <flask.json.tag.TaggedJSONSerializer object>
- session_class
alias of
SecureCookieSession
- get_signing_serializer(app)
Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets.
- Parameters:
app (Quart)
- Return type:
URLSafeTimedSerializer | None
- async open_session(app, request)
Open a secure cookie based session.
This will return None if a signing serializer is not available, usually if the config SECRET_KEY is not set.
- Parameters:
app (Quart)
request (BaseRequestWebsocket)
- Return type:
SecureCookieSession | None