How to persist user data after refreshing the page?

百般思念 提交于 2020-04-18 04:38:58

问题


I have couple of check boxes and input fields. When any of them are checked or any value entered to the input fields, I need to persist these data even after refreshing or URL location change.Can someone help me?


回答1:


You can use localStorage of HTML5

http://www.w3schools.com/html/html5_webstorage.asp




回答2:


Use cookies, they are the most reliable way to save data across browsers, also you can later access it server side. If you don't need expiration or advanced functionality you can use the $cookieStore, otherwise you should use something else.

Although, I would not recommend using this, unless is only for the user experience. If you are relying in this mechanism to give save-like functionality I would strongly recommend you search another approach



来源:https://stackoverflow.com/questions/26015452/how-to-persist-user-data-after-refreshing-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!