API Documentation

InMemorySessionInterface

class sanic_session.InMemorySessionInterface(domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name='session', secure: bool = False)
__init__(domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name='session', secure: bool = False)

MemcacheSessionInterface

class sanic_session.MemcacheSessionInterface(memcache_connection, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)
__init__(memcache_connection, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)

Initializes the interface for storing client sessions in memcache. Requires a client object establised with asyncio_memcache.

Args:
memcache_connection (aiomccache.Client):

The memcache client used for interfacing with memcache.

domain (str, optional):

Optional domain which will be attached to the cookie.

expiry (int, optional):

Seconds until the session should expire.

httponly (bool, optional):

Adds the httponly flag to the session cookie.

cookie_name (str, optional):

Name used for the client cookie.

prefix (str, optional):

Memcache keys will take the format of prefix+session_id; specify the prefix here.

sessioncookie (bool, optional):

Specifies if the sent cookie should be a ‘session cookie’, i.e no Expires or Max-age headers are included. Expiry is still fully tracked on the server side. Default setting is False.

samesite (str, optional):

Will prevent the cookie from being sent by the browser to the target site in all cross-site browsing context, even when following a regular link. One of (‘lax’, ‘strict’) Default: None

session_name (str, optional):

Name of the session that will be accessible through the request. e.g. If session_name is alt_session, it should be accessed like that: request.ctx.alt_session e.g. And if session_name is left to default, it should be accessed like that: request.ctx.session Default: ‘session’

secure (bool, optional):

Adds the Secure flag to the session cookie.

RedisSessionInterface

class sanic_session.RedisSessionInterface(redis_getter: Callable, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)
__init__(redis_getter: Callable, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)

Initializes a session interface backed by Redis.

Args:
redis_getter (Callable):

Coroutine which should return an asyncio_redis connection pool (suggested) or an asyncio_redis Redis connection.

domain (str, optional):

Optional domain which will be attached to the cookie.

expiry (int, optional):

Seconds until the session should expire.

httponly (bool, optional):

Adds the httponly flag to the session cookie.

cookie_name (str, optional):

Name used for the client cookie.

prefix (str, optional):

Memcache keys will take the format of prefix+session_id; specify the prefix here.

sessioncookie (bool, optional):

Specifies if the sent cookie should be a ‘session cookie’, i.e no Expires or Max-age headers are included. Expiry is still fully tracked on the server side. Default setting is False.

samesite (str, optional):

Will prevent the cookie from being sent by the browser to the target site in all cross-site browsing context, even when following a regular link. One of (‘lax’, ‘strict’) Default: None

session_name (str, optional):

Name of the session that will be accessible through the request. e.g. If session_name is alt_session, it should be accessed like that: request.ctx.alt_session e.g. And if session_name is left to default, it should be accessed like that: request.ctx.session Default: ‘session’

secure (bool, optional):

Adds the Secure flag to the session cookie.

AIORedisSessionInterface

class sanic_session.AIORedisSessionInterface(redis, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)
__init__(redis, domain: Optional[str] = None, expiry: int = 2592000, httponly: bool = True, cookie_name: str = 'session', prefix: str = 'session:', sessioncookie: bool = False, samesite: Optional[str] = None, session_name: str = 'session', secure: bool = False)

Initializes a session interface backed by Redis.

Args:
redis (Callable):

aioredis connection or connection pool instance.

domain (str, optional):

Optional domain which will be attached to the cookie.

expiry (int, optional):

Seconds until the session should expire.

httponly (bool, optional):

Adds the httponly flag to the session cookie.

cookie_name (str, optional):

Name used for the client cookie.

prefix (str, optional):

Memcache keys will take the format of prefix+session_id; specify the prefix here.

sessioncookie (bool, optional):

Specifies if the sent cookie should be a ‘session cookie’, i.e no Expires or Max-age headers are included. Expiry is still fully tracked on the server side. Default setting is False.

samesite (str, optional):

Will prevent the cookie from being sent by the browser to the target site in all cross-site browsing context, even when following a regular link. One of (‘lax’, ‘strict’) Default: None

session_name (str, optional):

Name of the session that will be accessible through the request. e.g. If session_name is alt_session, it should be accessed like that: request.ctx.alt_session e.g. And if session_name is left to default, it should be accessed like that: request.ctx.session Default: ‘session’

secure (bool, optional):

Adds the Secure flag to the session cookie.