Util to access cookie API
- Source:
Methods
(static) getCookie(name)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | cookie key name |
- Source:
Example
import { getCookie } from 'js-utils-pack';
getCookie('User');
// This will return 'Sonu'
(static) setCookie(name, value, exdays)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | sessionStorage key name |
value |
* | data to be stored in the key |
exdays |
number | number of days to remove the cookie from browser |
- Source:
Example
import { setCookie } from 'js-utils-pack';
setCookie('User', 'Sonu', 1)
// This will set a user cookie with Sonu as value and one day expiration time