The cookie library we have used is which is an open source library. We have't made any changes on the code so the usage is same from the library documentation.
usage
//Create a cookie, valid across the entire site:
Cookies.set('name', 'value');
//Create a cookie that expires 7 days from now, valid across the entire site:
Cookies.set('name', 'value', { expires: 7 });
//Create an expiring cookie, valid to the path of the current page:
Cookies.set('name', 'value', { expires: 7, path: '' });
//Read cookie:
Cookies.get('name'); // => 'value'
Cookies.get('nothing'); // => undefined
//Read all visible cookies:
Cookies.get(); // => { name: 'value' }
//Note: It is not possible to read a particular cookie by passing one of the cookie attributes (which may or may not have been used when writing the cookie in question):
Cookies.get('foo', { domain: 'sub.example.com' }); // `domain` won't have any effect...!
//The cookie with the name foo will only be available on .get() if it's visible from where the code is called; the domain and/or path attribute will not have an effect when reading.
//Delete cookie:
Cookies.remove('name');
//Delete a cookie valid to the path of the current page:
Cookies.set('name', 'value', { path: '' });
Cookies.remove('name'); // fail!
Cookies.remove('name', { path: '' }); // removed!