- A JS library where you can store two or three dimensional array to Session Storage or Local Storage
- object that stores and manipulates values in Session Storage.
- object that stores and manipulates values in Local Storage.
//Declaring object that will handle session storage
var my_sp = new SessionParser('session');
//Declaring object that will handle local storage
var my_lp = new SessionParser('local');
- setting up of key value pair in session or local storage.
sp.set('username','myUsername');
- fetching of key value pair in session or local storage.
var userName = sp.get('username');
- initializes a two dimensional array.
sp.init('mySession',{
saved : false, //Storing boolean value
list : [], //Defining the field as array, where you can push data object later on
note : "This is a note" //Storing string
});
- returns true or false if the session name is existing in session or local storage.
if(sp.isset('username')
{
//statement here...
}
- unsets a session name in session or local storage.
sp.unset('username');
- returns a two dimensional array of the session name stored in session or local storage.
var sessionData = sp.getData('mySession');
- storing two dimensional array to session name stored in session or local storage.
sp.setData('mySession',dataArray);
- fetching the value of a key in a session name stored in session or local storage.
var note = sp.getKey('mySession','note');
- fetching JSON Stringified array value of a key in a session name stored in session or local storage.
var listJSONString = sp.getKeyStringified('mySession','list');
- storing value to a specific key in a session name stored in session or local storage.
sp.setKey('mySession','saved',true);
- removing a specific key in a session name stored in session or local storage.
sp.removeField('mySession','note');
- removing a specific item from an array stored in a key in a session name.
sp.removeFieldKey('mySession','list',0);
In this case list is a field in mySession that holds an array value,defining the index will remove the specific record from the array. The example above means deleting the first record from list.
- adding a record to the array stored in a key in a session name.
sp.pushToKey('mySession','list',dataObject);
This is being used if the key holds an Array value.
- appending to a string stored in a key in a session name.
sp.appendToKey('mySession','note','The End');
This is being used if the key holds a String value.