Accessing client sessionStorage and localStorage

Hi,

In my application i have a callback setting some values to session storage, like so:

app.clientside_callback(
  """
  function(input_data) {
    sessionStorage.setItem("value", input_data);
  }
  """,
  Output("dummy-id", "value"),
  Input("input_data", "data"),

This is to keep some user options as the user navigates to other pages.
However, how can I actually read and access these values in the callbacks on the other pages? Ideally perhaps, I’d have a State(sessionStorage, “data”) argument or something to the reading callback. Is there any way to solve this?

E: Oh, and by the way. One of the reasons of using the sessionStorage here is to have potentially several callbacks writing to this storage. Dash will not allow me to have multiple writers to Store. I know this is a code smell, so I will gladly hear about alternative ways of solving this.

Thanks!

One option would be to use the MultiplexerTransform to enable multiple callbacks targeting the same output.

Hello @Bjeff,

What you need to do is have something where it syncs the client and server side data.

This can be done by adding a hidden button that you can click which is a clientside callback that targets the sessionStorage data and returns it from the client by using getItem.

I use this several places when dealing with dcc.Stores.