0

I have a page that show the name of user after login, but, if a press F5 the page reloads and the name does not appear. How can I persist this information in the session?

2
  • This is a very broad question. What backend are you using? Is it a single page application or are you using cookies? Commented Mar 10, 2014 at 20:05
  • 2
    My backend is Java using JAX-RS. Not using cookies, but, thinking use sessionStorage or localStorage. Commented Mar 10, 2014 at 20:10

3 Answers 3

1

Session Storage would be your first choice, take a look at the ngStorage module. I haven't tested it and it doesn't seem to be widely used but it's a good starting point even if you want to write your own implementation.

Though unless you have a good reason to go against cookies consider using the inbuilt $cookies service.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the $cookieStore service. Docs can be found at http://docs.angularjs.org/api/ngCookies/service/$cookieStore

Comments

0

If you are targeting modern browsers (i.e. IE8+), simply use sessionStorage if you only want the data to persist for the current session, or localStorage if you want the data to persist across multiple sessions. No need to use a third-party library. It's built in already.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.