Obtaining ID of Sanic Session

68 Views Asked by At

I'm placing session data in the Sanic in-memory session using the following code:

app = Sanic.get_app()
Session(app, interface=InMemorySessionInterface())
request.ctx.session['foo'] = 'bar'

How do I access the ID associated with this session? I need to send the ID to Twilio using the render function with a template. Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

I cannot comment on the Twilio integration as I have never used it, but you can access the session id from the session object:

session_id = request.ctx.session.sid