|
@@ -1,37 +1,38 @@
|
|
|
+import Cookies from 'js-cookie'
|
|
|
const TokenKey = 'GCLS_Token';
|
|
|
|
|
|
export function getSessionID() {
|
|
|
- const token = localStorage.getItem(TokenKey);
|
|
|
+ const token = Cookies.get(TokenKey);
|
|
|
const _token = token ? JSON.parse(token) : null;
|
|
|
return _token ? _token.session_id ?? '' : '';
|
|
|
}
|
|
|
|
|
|
export function getToken() {
|
|
|
- const token = localStorage.getItem(TokenKey);
|
|
|
+ const token = Cookies.get(TokenKey);
|
|
|
return token ? JSON.parse(token) : null;
|
|
|
}
|
|
|
|
|
|
export function setToken(token) {
|
|
|
const _token = typeof token === 'object' ? JSON.stringify(token) : '';
|
|
|
- localStorage.setItem(TokenKey, _token);
|
|
|
+ Cookies.set(TokenKey, _token, { expires: 10, });
|
|
|
}
|
|
|
|
|
|
export function removeToken() {
|
|
|
- localStorage.removeItem(TokenKey);
|
|
|
+ Cookies.remove(TokenKey);
|
|
|
}
|
|
|
|
|
|
const ConfigKey = 'GCLS_Config';
|
|
|
|
|
|
export function getConfig() {
|
|
|
- const config = localStorage.getItem(ConfigKey);
|
|
|
+ const config = Cookies.get(ConfigKey);
|
|
|
return config ? JSON.parse(config) : null;
|
|
|
}
|
|
|
|
|
|
export function setConfig(value) {
|
|
|
let _val = typeof value === 'object' ? JSON.stringify(value) : '';
|
|
|
- localStorage.setItem(ConfigKey, _val);
|
|
|
+ Cookies.set(ConfigKey, _val, { expires: 10, });
|
|
|
}
|
|
|
|
|
|
export function removeConfig() {
|
|
|
- localStorage.removeItem(ConfigKey);
|
|
|
+ Cookies.remove(ConfigKey);
|
|
|
}
|