I am using redux as state management in my application . I also use store concept and store the state in local storage for showing the state value even after the page refresh working fine but my concern is the states stored is exposed to the user . Is that a concern if yes how can I handle that
Asked
Active
Viewed 906 times
0
-
This question is likely to insight opinion based answers, so may not be the best for SO. See these instead: https://egghead.io/lessons/javascript-redux-persisting-the-state-to-the-local-storage and https://stackoverflow.com/questions/35305661/where-to-write-to-localstorage-in-a-redux-app for more details – OliverRadini Aug 10 '18 at 10:50
-
@OliverRadini i too refered that link before but they used localstorage to store the state but I'm asking is saving the data in localstorage is safer to attacks or we having any alternative way to do so – pageNotfoUnd Aug 10 '18 at 10:56
-
I think you're asking a different question, then; is it safe to store data in local storage? In which case see https://stackoverflow.com/questions/17280390/can-local-storage-ever-be-considered-secure and https://softwareengineering.stackexchange.com/questions/74155/how-secure-is-localstorage – OliverRadini Aug 10 '18 at 10:59
-
Whenever we call an action it update the store and create a brand new object completely . How you are going to use local storage? – Gobinda Aug 10 '18 at 11:35
-
const persistedState = localStorage.getItem('state') ? JSON.parse(localStorage.getItem('state')) : {}; export const store = createStore( rootReducer, persistedState, composedEnhancers ); – pageNotfoUnd Aug 10 '18 at 11:58
-
I think the question does not even relate to redux store, but can be generally reduced to: Should I store sensitive data in in local storage? NO, never. Should I store irrelevant state (is sidebar open?) in local storage? Yeah, why not. Basically you can say that with the right tools you can access the store anyhow: https://stackoverflow.com/questions/34373462/while-debugging-can-i-have-access-to-the-redux-store-from-the-browser-console – larrydahooster Aug 10 '18 at 12:42
-
You should read this as well: https://dev.to/rdegges/please-stop-using-local-storage-1i04 – larrydahooster Aug 10 '18 at 12:44
-
`const persistedState = localStorage.getItem('state') ? JSON.parse(localStorage.getItem('state')) : {};` this is my code for storing the persistedState to avoid state loss on page refresh without localstorage how could i store in redux store @larrydahooster – pageNotfoUnd Aug 10 '18 at 13:17