javascript - Setting up localStorage -


how can store multiple data in localstorage? using array doesn't seem work.

for(i=0;i<8;i++){    localstorage.vals[i]= item[i]; //vals[i] not work } 

use setitem() , getitem() methods of localstorage.

set object in localstorage.

var data = {}; (i = 0; < 8; i++) {     data[vals[i]] = item[i]; } localstorage.setitem('mydata', json.stringify(data)); 

to get it:

var mydata = json.parse(localstorage.getitem('mydata')); 

update

to check if data exists in localstorage:

if (localstorage.getitem('mydata')) {     // exists } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -