diff --git a/dlib.js b/dlib.js index f5a0946..40bfe49 100644 --- a/dlib.js +++ b/dlib.js @@ -34,4 +34,22 @@ DLib.createBox = ({title, text, titleType='h3', textType='span', breakAfterTitle //return box; } + + +/** + * @param {string} name - The name of the cookie + * @param {string} value - The cookie's value + * @param {number} expire - In how many seconds should the cookie expire + */ +DLib.createCookie = (name, value, expire=31536000) => { + document.cookie = `${name}=${value};secure;max-age=${expire};same-site=lax;`; +}; + +/** + * + * @param {string} name - The cookie to delete + */ +DLib.deleteCookie = (name) => { + document.cookie = `${name}="";max-age=0;`; +} // @license-end