aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils
diff options
context:
space:
mode:
authorOsmium Sorcerer <os@sof.beauty>2026-04-07 02:55:26 +0000
committerstonedDiscord <Tukz@gmx.de>2026-05-04 22:56:49 +0200
commit2f57c6c54bceb7d1be061d6f37b501dd6a58eaa4 (patch)
tree959943f8d91464b5d8beae0f7bf61e6262e4f33d /webAO/utils
parentfcaee3675fde49e2cd5bb8103d1c1f60863bc42c (diff)
Replace cookies with localStorage
Cookies's use case is to store persistent data and send it to the server in subsequent requests, such as to remember logged-in sessions. WebAO is using them to store site settings like ad-hoc hash tables that require parsing and serialization. As a nasty side-effect of how cookies work, clients send all their settings every time they connect to the server. Server has absolutely no use for them, but each client sends them anyway, which is an uncalled-for privacy leak. Remove this mechanism entirely, switch to localStorage which serves exactly the purpose of per-origin store with data that never leaves the browser.
Diffstat (limited to 'webAO/utils')
-rw-r--r--webAO/utils/getCookie.ts26
-rw-r--r--webAO/utils/setCookie.ts12
2 files changed, 0 insertions, 38 deletions
diff --git a/webAO/utils/getCookie.ts b/webAO/utils/getCookie.ts
deleted file mode 100644
index 73736885..00000000
--- a/webAO/utils/getCookie.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * read a cookie from storage
- * got this from w3schools
- * https://www.w3schools.com/js/js_cookies.asp
- * @param {string} cname The name of the cookie to return
- */
-const getCookie = (cname: string) => {
- try {
- const name = `${cname}=`;
- const decodedCookie = decodeURIComponent(document.cookie);
- const ca = decodedCookie.split(";");
- for (let i = 0; i < ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) === " ") {
- c = c.substring(1);
- }
- if (c.indexOf(name) === 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- } catch (error) {
- return "";
- }
-};
-export default getCookie;
diff --git a/webAO/utils/setCookie.ts b/webAO/utils/setCookie.ts
deleted file mode 100644
index 421fe81f..00000000
--- a/webAO/utils/setCookie.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* eslint @typescript-eslint/no-explicit-any: "off" */
-
-/**
- * set a cookie
- * the version from w3schools expects these to expire
- * @param {string} cname The name of the cookie to return
- * @param {any} value The value of that cookie option
- */
-const setCookie = (cname: string, value: any) => {
- document.cookie = `${cname}=${value};SameSite=Strict`;
-};
-export default setCookie;