Sunday 31 December 2017

javascript - In what situation we must use localstorage instead of the cookies?





I'm trying to develop a html5 mobile web application using the
sencha touch. I need to save client's data in browser storage for a long time. At first
i used a localstorage to save them. But my colleague recommended to use cookies instead
of the localstorage. I need to warn you that i don't use user's data in server-side and
size of data is small. What should i use localstorage or cookies in this
case?



Answer




I think in this situation local Storage would
do better,because




  1. Cookies
    are used by server side and you said ,you don't use users's data in server
    side.

  2. Your data size is small and you need to store it
    for long time,cookie has expiration date,but with local storage there is no such,either
    you have remove it programmatic-ally using java script or by clearing browser
    cache.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...