Typescript Package For Localstorage data manipulation mimicing laravel's session methods.
A typescript package that enables you to work with data in your localstorage (currently made for frontend applications) using laravel's session methods like get, put, forget, flush, push, pull and has. The session data is encrypted to give your data some sense of security.
The prefered installation method is via npm. Run:
npm install laravel-ts-session
To use the package, you need to import it into your component:
import Session from 'laravel-ts-session';
Then you can instantiate it
session: Session = new Session();
Find below the methods currently avaialble for session data manipulation
Retrieving data from session
this.session.get('key')
Inserting a new data in session
this.session.put('key', 'value')
Removing a particular data from session
this.session.forget('key')
Removing all data from session (clear)
this.session.flush()
Retrieving data from session & removing it afterwards.
this.session.pull('key')
If the values of the data is an array/object, you can push new values into the data with the push method
this.session.push('key', 'new values')
A check to see if a key exists in session
this.session.has('key')
You can pass an optional parameter to the methods which would returned if returned if the specified key does not exist in the session
this.session.get('key', 'default')