sessiontwiliosanic

Obtaining ID of Sanic Session


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.


Solution

  • 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