The user session is designed to persist data in memory through the life cycle of a chat session. Each user session is unique to a user and a given chat session.Documentation Index
Fetch the complete documentation index at: https://docs.chainlit.io/llms.txt
Use this file to discover all available pages before exploring further.
Why use the user session?
Let’s say you want to keep track of each chat session message count. A naive implementation might look like this:Naive Example
counter.
This is where the user session comes in. Let’s rewrite the above example using the user session:
Correct example
User Session Default Values
By default, Chainlit stores chat session related data in the user session. The following keys are reserved for chat session related data:The session id.
Only set if you are enabled Authentication. Contains the
user object of the user that started this chat session.
Only relevant if you are using the Chat
Profiles feature. Contains the chat profile
selected by this user.
Only relevant if you are using the Chat
Settings feature. Contains the chat
settings given by this user.