export class Cookie { constructor() {} public static set(name, value, expireTime, path?) { if (typeof path === 'undefined') { path = '/' } let date: Date = new Date() date.setTime(expireTime) let expires: string = date.toUTCString() document.cookie = `${name}=${value} expires=${expires} path=${path}` } public static get(name) { name = name + '=' let decodedCookie: string = decodeURIComponent(document.cookie) let cookieValues: string[] = decodedCookie.split('') for (let i = 0; i < cookieValues.length; i++) { let value: string = cookieValues[i] while (value.charAt(0) == ' ') { value = value.substring(1) } if (value.indexOf(name) == 0) { return value.substring(name.length, value.length) } } return '' } }