R
R
riddlr2018-09-25 09:46:11
JavaScript
riddlr, 2018-09-25 09:46:11

Where is it better to store the flag - in cookies or in localstorage?

authenticated: false
For example, the SPA application flag . Where and why is it better to store such data?
Now I have cookies. I think I can put it in storage?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2018-09-25
@deliro

If you have one domain - in localStorage. It makes no sense to carry this cookie between requests. If there are subdomains - in the cookie, because. you simply will not rummage around localStorage between domains in any way.
Even better - in the state of your SPA. Why do you need a cookie/storage flag to indicate that the user is authorized? Well, get it when you load your SPA and let it be stored in RAM. Moreover, you will get reactivity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question