Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « flask.sessions »

Classe « SessionInterface »

Informations générales

Héritage

builtins.object
    SessionInterface

Définition

class SessionInterface(builtins.object):

Description [extrait de SessionInterface.__doc__]

The basic interface you have to implement in order to replace the
    default session interface which uses werkzeug's securecookie
    implementation.  The only methods you have to implement are
    :meth:`open_session` and :meth:`save_session`, the others have
    useful defaults which you don't need to change.

    The session object returned by the :meth:`open_session` method has to
    provide a dictionary like interface plus the properties and methods
    from the :class:`SessionMixin`.  We recommend just subclassing a dict
    and adding that mixin::

        class Session(dict, SessionMixin):
            pass

    If :meth:`open_session` returns ``None`` Flask will call into
    :meth:`make_null_session` to create a session that acts as replacement
    if the session support cannot work because some requirement is not
    fulfilled.  The default :class:`NullSession` class that is created
    will complain that the secret key was not set.

    To replace the session interface on an application all you have to do
    is to assign :attr:`flask.Flask.session_interface`::

        app = Flask(__name__)
        app.session_interface = MySessionInterface()

    .. versionadded:: 0.8
    

Constructeur(s)

Signature du constructeur Description
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
pickle_basedFalse

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
get_cookie_domain(self, app: 'Flask') -> Optional[str] Returns the domain that should be set for the session cookie. [extrait de get_cookie_domain.__doc__]
get_cookie_httponly(self, app: 'Flask') -> bool Returns True if the session cookie should be httponly. This [extrait de get_cookie_httponly.__doc__]
get_cookie_name(self, app: 'Flask') -> str Returns the name of the session cookie. [extrait de get_cookie_name.__doc__]
get_cookie_path(self, app: 'Flask') -> str Returns the path for which the cookie should be valid. The [extrait de get_cookie_path.__doc__]
get_cookie_samesite(self, app: 'Flask') -> str Return ``'Strict'`` or ``'Lax'`` if the cookie should use the [extrait de get_cookie_samesite.__doc__]
get_cookie_secure(self, app: 'Flask') -> bool Returns True if the cookie should be secure. This currently [extrait de get_cookie_secure.__doc__]
get_expiration_time(self, app: 'Flask', session: flask.sessions.SessionMixin) -> Optional[datetime.datetime] A helper method that returns an expiration date for the session [extrait de get_expiration_time.__doc__]
is_null_session(self, obj: object) -> bool Checks if a given object is a null session. Null sessions are [extrait de is_null_session.__doc__]
make_null_session(self, app: 'Flask') -> flask.sessions.NullSession Creates a null session which acts as a replacement object if the [extrait de make_null_session.__doc__]
open_session(self, app: 'Flask', request: 'Request') -> Optional[flask.sessions.SessionMixin] This method has to be implemented and must either return ``None`` [extrait de open_session.__doc__]
save_session(self, app: 'Flask', session: flask.sessions.SessionMixin, response: 'Response') -> None This is called for actual sessions returned by :meth:`open_session` [extrait de save_session.__doc__]
should_set_cookie(self, app: 'Flask', session: flask.sessions.SessionMixin) -> bool Used by session backends to determine if a ``Set-Cookie`` header [extrait de should_set_cookie.__doc__]

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__