# Internal state variable

**URL:** <https://community.plotly.com/t/internal-state-variable/4702>\
**Category:** Dash Python\
**Created:** [June 29, 2017, 3:03pm UTC](https://community.plotly.com/t/internal-state-variable/4702 "2017-06-29T15:03:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartkeulen](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bartkeulen](https://community.plotly.com/u/bartkeulen)\
**Post date:** [June 29, 2017, 3:03pm UTC](https://community.plotly.com/t/internal-state-variable/4702/1 "2017-06-29T15:03:15Z")

</div>

Hi,

First I quickly want to say that this is a great project, exactly what I was looking for!

I am making a display with multiple pages (like dash-doc with the radio-buttons for chapters) and I want to share states between the pages (like a a page to select filters and a graph page). For now I have added `self.states = {}` to the Dash class, but this does not work when multiple people are using the dashboard since this variable is shared. I would probably need to store it on the client side, does anybody have any recommendations for this?

You can find my current code [here](https://github.com/BartKeulen/drl/tree/master/drl/dashboard).

Bart

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [June 29, 2017, 3:10pm UTC](https://community.plotly.com/t/internal-state-variable/4702/2 "2017-06-29T15:10:12Z")

</div>

Sharing state on the backend isn’t possible right now. Dash apps are meant to be run on multiple processes where there isn’t access to common memory. Stateful backends also make it multi-user sessions harder to reason about.

Could you go into a little bit more detail about what you’d like to share between pages? A simple code example would be helpful here. Thanks!

---

<div class="post-metadata">

**Author:** ![Vlad](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/vlad/32/1369_2.png) [@Vlad](https://community.plotly.com/u/Vlad)\
**Post date:** [July 8, 2017, 9:51pm UTC](https://community.plotly.com/t/internal-state-variable/4702/3 "2017-07-08T21:51:55Z")

</div>

I am creating lots of hidden dummy dropdowns to store “state” - It works well.  
You can then access them in callbacks using State(), instead of Input(). Otherwise you most likely create cycle dependancies.

---

<div class="post-metadata">

**Author:** ![bartkeulen](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bartkeulen](https://community.plotly.com/u/bartkeulen)\
**Post date:** [July 10, 2017, 2:30pm UTC](https://community.plotly.com/t/internal-state-variable/4702/4 "2017-07-10T14:30:02Z")

</div>

So using an internal state variable is a bad idea for a few reasons. Right now I am figuring out how to use sessions or cookies to store that information, so it is all client dependent. But I haven’t figured out how to exactly implement that with Dash.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [July 10, 2017, 5:16pm UTC](https://community.plotly.com/t/internal-state-variable/4702/5 "2017-07-10T17:16:31Z")

</div>

> I am making a display with multiple pages (like dash-doc with the radio-buttons for chapters) and I want to share states between the pages

I just added two new components that might help out with the multi-page pattern. See [Single Page App ("SPA") URL / Multi Page Support - Proposal and Development Preview · Issue #77 · plotly/dash · GitHub](https://github.com/plotly/dash/issues/77) for some more details.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [July 10, 2017, 5:17pm UTC](https://community.plotly.com/t/internal-state-variable/4702/6 "2017-07-10T17:17:45Z")

</div>

> [@Vlad](#):
>
> I am creating lots of hidden dummy dropdowns to store “state” - It works well.  
> You can then access them in callbacks using State(), instead of Input().

You could also maybe do something like display a `div` and set `children` to be `json.dumps(your_state)`.
