- class Pyjoyment.Sessions.Pyjoyment_Sessions[source]¶
Pyjoyment.Sessionsinherits all methods fromPyjo.Baseand implements the following new ones.- cookie_domain: str | None¶
domain = sessions.cookie_domain sessions.cookie_domain = '.example.com'
Domain for session cookies, not defined by default.
- cookie_name¶
name = sessions.cookie_name sessions.cookie_name = 'session'
Name for session cookies, defaults to
pyjoyment.
- cookie_path¶
path = sessions.cookie_path sessions.cookie_path = '/foo'
Path for session cookies, defaults to
/.
- default_expiration¶
time = sessions.default_expiration sessions.default_expiration = 3600
Default time for sessions to expire in seconds from now, defaults to
3600. The expiration timeout gets refreshed for every request. Setting the value to0will allow sessions to persist until the browser window is closed, this can have security implications though. For more control you can also use theexpirationandexpiressession values.# Expiration date in seconds from now (persists between requests) c.session(expiration=604800) # Expiration date as absolute epoch time (only valid for one request) c.session(expires=time.time() + 604800) # Delete whole session by setting an expiration date in the past c.session(expires=1)
- deserialize: Callable[[bytes], Any]¶
cb = sessions.deserialize sessions.deserialize = lambda data: ...
A callback used to deserialize sessions, defaults to
Pyjo.JSON.decode_json().sessions.deserialize = lambda data: {}
- load(c: Pyjoyment.Controller.object) None[source]¶
sessions.load(Pyjoyment.Controller.new())
Load session data from signed cookie.
- partitioned: bool | None¶
boolean = sessions.partitioned sessions.partitioned = boolean
Partitioned flag, this is to be used in accordance to the CHIPS amendment to RFC 6265.
Note that this attribute is EXPERIMENTAL because even though most commonly used browsers support the feature, there is no specification yet besides this draft.
Partitioned cookies are held within a separate cookie jar per top-level site.
- samesite: str | None¶
samesite = sessions.samesite sessions.samesite = 'Strict'
Set the SameSite value on all session cookies, defaults to
Lax.# Disable SameSite feature sessions.samesite = None
- secure: bool | None¶
boolean = sessions.secure sessions.secure = boolean
Set the secure flag on all session cookies, so that browsers send them only over HTTPS connections.
- serialize: Callable[[dict[str, Any]], bytes]¶
cb = sessions.serialize sessions.serialize = lambda session: ...
A callback used to serialize sessions, defaults to
Pyjo.JSON.encode_json().sessions.serialize = lambda session: b''