I'm building an interactive Streamlit application and need to understand how to maintain state across user interactions. Please explain what Streamlit's session state is, how to set up and modify variables within it, and specifically how to use callbacks with interactive widgets to update the state.
Navigate to 'docs.streamlit.io'. Click on 'Develop'. Click on 'Concepts'. Click on 'Session State'. Read the 'What is State?' section to define session state. Read the 'Initialization' section to understand how to initialize session state variables. Read the 'Reads and updates' section to learn how to update session state variables. Read the 'Example 2: Session State and Callbacks' section to understand how callbacks are used with widgets. Synthesize all gathered information into a concise answer.
The agent successfully navigates to the 'Session State' page on docs.streamlit.io. The agent defines session state as a way to share variables between reruns for a given user session. The agent explains that session state variables can be initialized using dictionary-like assignment (e.g., `st.session_state['key'] = value`). The agent explains that session state variables can be updated by assigning new values to their keys (e.g., `st.session_state.key = new_value` or `st.session_state['key'] = new_value`). The agent explains that callbacks are functions passed to widget parameters (like `on_change` or `on_click`) that execute when the widget is interacted with, allowing them to modify session state.