rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.94k stars 866 forks source link

Question: Can we use persist state store in cookies? #1296

Closed prashantpandey9 closed 3 years ago

prashantpandey9 commented 3 years ago

Is there any option to save the hydrated state in the cookies instead of local storage? I think it is dangerous to store auth data in local storage.

Please resolve my doubt!

VictorPulzz commented 3 years ago

@prashantpandey9 There is nothing wrong with storing data in localstorage, if someone wants to hack you, then it is not a problem to take data away with cookies or with locvalstorage. But you still store all data in an encrypted format.

But if you want to use cookies, unfortunately there is no standard solution. There is such a plugin https://github.com/abersager/redux-persist-cookie-storage, I personally do not use it, I wrote my own solution (I need cookies for ssr)

prashantpandey9 commented 3 years ago

@VictorPullzz Thanks for your reply!!

bryanltobing commented 2 years ago

@VictorPulzz could you provide your workaround. I also need to store the state cookies for authentication in server-side rendering

geekact commented 2 years ago

Maybe using cookie storage is only way to share data between browser and server. Since there's maximum size per cookie(4096 bytes) limitation, we should only share the first screen data.