0

I am new to Angular JS, have experience on building spring web applications.

My requirement is to store the some session preferences (Not part of the user Model/entity) into session. I need to use them through out the application.

I couldn't find the right way to do it. I found some options, need suggestion on which one to use it.

ngStorage - can access Local/session storage and store attributes in it.

LocalStorageService - another githubproject, i can use it to store in session storage/ local storage.

Based on the articles i found, localstorage keeps the data even after logout, so have to make sure i clean all of them after logout.

What is the common practice to store session attributes? I am planning to use ngStorage directive and use sessionstorage and store it by encoding with Base64. Is it a good way to do it?

I am using Java 1.7 and Angular JS for building an application. I have used JHipster to generate the application.

Any Help Appriciated!!!!

S Neeli
  • 1
  • 1

2 Answers2

0

welcome! Well, depends the situation, localStorage is an excellent option to store attributes, but yes, it has some limitations and you have to remember to delete this. Another options is to use Cookies of angular project to store attributes on Client Side. I used in some projects and works perfectly for my use case. But if you are using Java, the best way is protect this session attributes using Java HttpServletSessions. I Hope it helps.

Túlio Castro
  • 1,313
  • 10
  • 17
  • Thanks for the response. But I am using restful java services on the backend. I cannot really use HTTPServletSessions to store the data. Any idea on sessionStorage instead of localStorage? – S Neeli Oct 17 '15 at 04:19
0

i had the same issue and i resolved by find the answer of this question: https://stackoverflow.com/a/922058/5995665 I hope it helps.

Community
  • 1
  • 1