What is the difference between $ cookies and localStorage?

what are cookies and localstorage.

$ cookies.myFavorite = 'Steve jobs'; 


localStorage.myFavorite = 'Steve jobs'; 
+3
source share
2 answers

$ cookies is an Angular module that acts as a cookie and terminates them in Angular. Cookies have less storage capacity than localStorage (4k rather than 5 m), and have the ability to customize to invite the visitor to use / accept every time you try to use it. This can quickly weaken the user's work. Cookies are not recommended for long-term storage of information in the browser for precisely these reasons. Cookies also have a reputation among technologists who are illiterate for the spread of viruses or otherwise harmful, neither of which deserve or are completely true.

localStorage ( sessionStorage) HTML5 . , , . cookie, , . , , . -.

localStorage , . localStorage, localStorage.removeItem(itemName).

sessionStorage , . , sessionStorage , . , , ..

, , . , .

+3

$cookie , .

localStorage .

0

All Articles