IKHSAN
ENID Baca dalam Bahasa Indonesia

opendesk

Public
Branch
main
Latest commit
08d9f3328 October 2026

userStorage.ts

Open 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";
}
bytes
528
lines
14
Type
ts
Latest commit
28 October 2026