Based on your description I think your database table structure is as follow:
ID | Username | IsLoggedIn (112, 22, are little bit confusing??)
iterate over your table and put all into one php array (maybe with class objects; so you have better json structure):
//helper class
class dataset
{
public $id;
public $username;
public $IsLoggedIn; // or something else
}
// .... iterating over table
//export to json:
$output = json_encode($yourDatasetArray);
// a few other operations
//...
// output your json-string:
echo $output;
The last example code can also be used as backend for an ajax request (maybe better method when working with json). Next you implement your client code like @rob explained before.
Documentation about local storage as well as session storage can be found here:
MDN Documentation