Looking for methods to prevent data from persisting between sessions

Shot in the dark here, but I was wondering if there is an easy way to make it so that data is not persisted amongst user sessions.

Long story short, I accidentally built my app around an object that is a global variable. Initially, I was not aware of how this breaks your app as I did not come across any issues given that I was running my app locally. Once I deployed, I noticed that the app was persisting data stored in that global variable between sessions.

I am aware that having the object stored in dcc.store is probably the best solution, however, I was wondering if there is an alternative method to quickly patch things up. I am not looking to have any data whatsoever persist on reload, so that is not a concern at all for me.

I am not sure how easy it would be to re-factor my code such that the object variable is stored in dcc.store, as I have not seen many examples of an object/class being stored that way.

Any insight, guidance, or advice would be appreciated

dcc.store is probably they way to go but you might be able to throw a solution together by updating the data on each page load. Hard to tell without more information or an example app that replicates the issues.

import datetime

import dash
from dash import html

def serve_layout():
    return html.H1('The time is: ' + str(datetime.datetime.now()))

app.layout = serve_layout

if __name__ == '__main__':
    app.run(debug=True)
1 Like

Yeah, I ended up biting the bullet and putting the time into making dcc.store work.

1 Like

Just in case anyone comes across this, my main issue was storing the global class object I had in dcc.store. I handled this by using jsonpickle.