From 3b612514f977479fe23191d88720ee95d44ca736 Mon Sep 17 00:00:00 2001 From: Roux S Date: Thu, 18 Nov 2021 11:55:17 +0000 Subject: [PATCH 1/2] add createcookie --- dlib.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlib.js b/dlib.js index f5a0946..0e337d2 100644 --- a/dlib.js +++ b/dlib.js @@ -34,4 +34,14 @@ 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;`; +}; // @license-end From cc1c5f6840f93c5f2a19d7e7cba8cb992e46781d Mon Sep 17 00:00:00 2001 From: Roux S Date: Thu, 18 Nov 2021 11:58:45 +0000 Subject: [PATCH 2/2] Add deletion of cookies --- dlib.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlib.js b/dlib.js index 0e337d2..40bfe49 100644 --- a/dlib.js +++ b/dlib.js @@ -44,4 +44,12 @@ DLib.createBox = ({title, text, titleType='h3', textType='span', breakAfterTitle 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