IKHSAN
EN Read in EnglishID

opendesk

Publik
Branch
main
Commit terakhir
08d9f3328 Oktober 2026

userStorage.ts

Buka raw
import { useStorage } from "@vueuse/core";

/** localStorage scoped to the signed-in agent, so nothing personal survives a
 * shift handover. Reads the session cookie, not the auth store — this runs at
 * module load, before pinia exists. */
export function userStorage<T>(key: string, fallback: T) {
  return useStorage<T>(`${key}:${sessionUserId()}`, fallback);
}

function sessionUserId(): string {
  const cookies = new URLSearchParams(document.cookie.split("; ").join("&"));
  return cookies.get("user_id") || "guest";
}
byte
528
baris
14
Jenis
ts
Commit terakhir
28 Oktober 2026