JavaScript · Junior · Question 44 of 75

How does localStorage differ from sessionStorage?

Explanation

Both store strings per origin, a few megabytes in size, and aren't sent to the server (unlike cookies). sessionStorage is also isolated per tab. Storing tokens and secrets there is unsafe: any script on the page can read them.

Further reading

Problem with a question

JavaScript · Junior · question 44

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz