Is there a way to store state across page refreshes that is local to a browser tab?
Unanswered
Drever posted this in #help-forum
DreverOP
I have state I would normally keep in the URL but can't for security reasons. Sessions cookies wouldn't work as the state needs to be tab-local, and session cookies are shared between browser tabs. I'd also rather not store the data in a cookie and can't store it in localStorage for the same reason I can't put it in the URL.
10 Replies
So it's only available for that single tab, opening a diff tab with the same page will show different data right @Drever
@Arinji So it's only available for that single tab, opening a diff tab with the same page will show different data right <@599910994101272586>
You can store state in local storage and different tabs would have access to the same data.
sorry scratch that didnt read the question fully.
sorry scratch that didnt read the question fully.
There is no other option for cross environment sharing. You could store the data on the backend, any other way to store the data on the front end would be exploitable for whatever security your trying to implement.
for all intensive purposes each tab is its own environment unless linking via local storage, cookies, or backend datastore.
yea you need to use a db for this
Wait maybe I misunderstood again.... you need to store the state per tab? wouldnt
useState() work for this? I may not understand.True. Yeah, I dont understand the security concern about using local storage. If its on the page its already acessible to anyone that wants to get at it.
local storage vs storing in memory = same thing.
anyways, I think we gave him a proper response 🙂