Use Flask session

The Flask session global must be accessed within a request context. That means that you can’t define it within a static layout that is evaluation when the app first loads. You need to use it within a dynamic layout, where app.layout is assigned a function object, meaning that the function will be evaluated on each page load. See the Updates on Page Load section in the Dash Guide.

2 Likes