'Persist state data in angular without using LocalStorage when refreshing page
I'm trying to make a webpage that shows different content depending on the type of user (teacher or student). I was saving the session data inside localStorage ('student' or 'teacher' string) because if i save the data inside a service when the page is refreshed the data is deleted.
The problem is that any user can change the data from localStorage from their browser (for example a user can see the teacher content if they change the value inside localstorage from student to teacher and refreshing the page).
I know i'm probably doing it in the wrong way by saving the data without encryption inside localstorage but i wanted to ask if there is a better option to achive what i'm trying to do.
Solution 1:[1]
I guess you will need a full application with backend stuff ( authentification with token...) to do what you are trying to achieve.
You could make a small encryption in the client side with third-party library (for example : https://www.npmjs.com/package/localstorage-encrypt) to make sure that you have non-human readable values (but safety will be for sure minimal still)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Blastouz |
