summaryrefslogtreecommitdiff
path: root/scripts/cookie.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cookie.js')
-rw-r--r--scripts/cookie.js54
1 files changed, 27 insertions, 27 deletions
diff --git a/scripts/cookie.js b/scripts/cookie.js
index 44a0be9..9c88963 100644
--- a/scripts/cookie.js
+++ b/scripts/cookie.js
@@ -1,36 +1,36 @@
'use strict';
class Cookies {
- static getCookie(name){
- let cookies = document.cookie.split(";");
- for(let i in cookies) {
- let cname = cookies[i].trim().split("=")[0];
- if(cname == name){
- return cookies[i].trim().slice(name.length + 1);
- }
- }
- return "";
- }
+ static getCookie(name){
+ let cookies = document.cookie.split(";");
+ for(let i in cookies) {
+ let cname = cookies[i].trim().split("=")[0];
+ if(cname == name){
+ return cookies[i].trim().slice(name.length + 1);
+ }
+ }
+ return "";
+ }
- static setCookie(name, value, data = {SameSite: "Strict"}) {
- let extra = "";
+ static setCookie(name, value, data = {SameSite: "Strict"}) {
+ let extra = "";
- for(let key in data)
- {
- extra += "; " + key + "=" + data[key];
- }
+ for(let key in data)
+ {
+ extra += "; " + key + "=" + data[key];
+ }
- document.cookie = name + "=" + value + extra;
- }
+ document.cookie = name + "=" + value + extra;
+ }
- static setYearCookie(name, value) {
- var date = new Date(Date.now());
- date.setFullYear(date.getFullYear() + 1);
- Cookies.setCookie(name, value, {SameSite: "Strict", expires: date.toUTCString()});
- }
+ static setYearCookie(name, value) {
+ var date = new Date(Date.now());
+ date.setFullYear(date.getFullYear() + 1);
+ Cookies.setCookie(name, value, {SameSite: "Strict", expires: date.toUTCString()});
+ }
- static removeCookie(name) {
- var date = new Date(0);
- Cookies.setCookie(name, "", {SameSite: "Strict", expires: date.toUTCString()});
- }
+ static removeCookie(name) {
+ var date = new Date(0);
+ Cookies.setCookie(name, "", {SameSite: "Strict", expires: date.toUTCString()});
+ }
}