from bungeni.alchemist import Session session = Session() session['username'] = 'JohnDoe' session['is_admin'] = True # Retrieving session values username = session.get('username') is_admin = session.get('is_admin')
from bungeni.alchemist import Session # Creating new session session_id = '123456' session = Session(session_id=session_id) session['username'] = 'JaneDoe' session.save() # Retrieving existing session session = Session(session_id=session_id) username = session.get('username')In this example, we first create a new session with a specific session ID and set the username to JaneDoe. We then save the session data. Later, we retrieve this session by specifying the session ID and retrieve the username using the session.get() method. The bungeni.alchemist Session package is part of the Alchemist library.