Tip
This page only contains information on the Jt.sessionState
API. For a deeper dive into Session State and how to use it, check out Session State.
Return the session state Map of the session. A session corresponds to an opened tab of the app.
The session state is maintained across re-runs. Values can be stored and persisted in this map.
Method Signatures and Parameters | |
Jt.sessionState() | |
Returns after .use() | |
(io.jeamlit.datastructure.TypedMap) | The current io.jeamlit.datastructure.TypedMap value of the component. |
Examples
Basic counter with session state
import io.jeamlit.core.Jt;
public class CounterApp {
public static void main(String[] args) {
// initialize a counter
Jt.sessionState().putIfAbsent("counter", 0);
if (Jt.button("Increment").use()) {
Jt.sessionState().computeInt("counter", (k, v) -> v + 1);
}
Jt.text("Counter: " + Jt.sessionState().get("counter")).use();
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.