# Flask sessions to maintain client-specific global variables in Dash

**URL:** <https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610>\
**Category:** Dash Python\
**Created:** [February 6, 2020, 5:54pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610 "2020-02-06T17:54:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rp2532](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rp2532](https://community.plotly.com/u/rp2532)\
**Post date:** [February 6, 2020, 5:54pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/1 "2020-02-06T17:54:49Z")

</div>

I’m building a dash app that allows user to upload files, processes data from those files, and has to store the results (for further functionality). I initially used a global variable to do this - but realized this is a bad idea because it introduces cross-talk between different client sessions (i.e. each client’s page accesses the data uploaded by other clients sessions, whereas in reality the data seen by each client ought to be independent of anything other clients might upload.

I’m hoping to use Flask-Session to accomplish what I need - something along the lines of lhc’s answer to [this thread](https://stackoverflow.com/questions/32815451/are-global-variables-thread-safe-in-flask-how-do-i-share-data-between-requests) - the third answer on the thread.

At first glance it seems not to work - upon using a variable in the session dict (session[‘client\_specific\_data’]) to store the data, I still see cross talk between different client sessions.

Could someone tell me if what I am trying to do is possible and whether flask sessions are a way to accomplish it? Can provide code examples if necessary.

---

<div class="post-metadata">

**Author:** ![Milo\_Tronics](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Milo\_Tronics](https://community.plotly.com/u/Milo_Tronics)\
**Post date:** [November 4, 2020, 9:45pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/2 "2020-11-04T21:45:31Z")

</div>

Hi rp2532.  
Did you ever find a solution to this?

---

<div class="post-metadata">

**Author:** ![rp2532](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rp2532](https://community.plotly.com/u/rp2532)\
**Post date:** [November 13, 2020, 7:41pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/3 "2020-11-13T19:41:48Z")

</div>

I ended up using hidden Divs in the page to store the data that I needed for further processing. This data was in the form of pickled objects of a class that I defined. I did not end up using client sessions.

---

<div class="post-metadata">

**Author:** ![rohan\_sharma](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rohan\_sharma](https://community.plotly.com/u/rohan_sharma)\
**Post date:** [August 4, 2021, 3:10pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/4 "2021-08-04T15:10:39Z")

</div>

Hey rp2532. I am facing the same issue. I want to get the data uploaded from the clients on my dash app and then perform some calculation and show it to them, but should not clash with other client working in the process parallelly.

I am generating a UUID and using that UUID I am creating location for storing the files and access them for the same UUID using state parameter in callbacks. The issue is, I cannot generate a different UUID for the same app running locally on my browser and in incognito.

Any suggestion in this regard will be very useful.

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [August 4, 2021, 3:14pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/5 "2021-08-04T15:14:21Z")

</div>

Har you tried the server side output in dash-extensions?

> **[GitHub - thedirtyfew/dash-extensions](https://github.com/thedirtyfew/dash-extensions#serversideoutputtransform)**
>
> Contribute to thedirtyfew/dash-extensions development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![rohan\_sharma](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rohan\_sharma](https://community.plotly.com/u/rohan_sharma)\
**Post date:** [August 4, 2021, 5:15pm UTC](https://community.plotly.com/t/flask-sessions-to-maintain-client-specific-global-variables-in-dash/34610/6 "2021-08-04T17:15:37Z")

</div>

Thank You Emil. I will check this one out. Thank You
