javascript - Searching and clearing LocalStorage -


i know, localstorage supports 5mb only. in our application planning use localstorage (sessionstorage doesn't fits our need, since support multiple tabs). there 1 big javascript object serialized , stored in localstorage, in future may exceed 15 objects not more that.

the problem is, clearing localstorage. since our application allows user login in multiple ways (sso etc...). without landing in login page, can login our application , signing off in other application sign off in our application or close browser. security reason, need clean localstorage once user session over.

so planned store personid in localstorage, in every page request along html response send personid server, , if doesn't match localstorage's personid clear localstorage.

my doubt here is, search in localstorage not asynchronous take time search personid out of 15 keys (which has large string value)?

localstorage.setitem("personid", 1234); localstorage.setitem("object1", "a big serialized form of javascript object gets stored");  

writing values fast , there no significant difference between large , short values: http://jsperf.com/local-storage-set

you can test search on site too... share search code too, others can take on it.


Comments