ChristopherJKoen's picture
Initial React Transcription
1643ce8
raw
history blame contribute delete
760 Bytes
const SESSION_KEY = "repex_session_id";
export function getStoredSessionId(): string {
return localStorage.getItem(SESSION_KEY) || "";
}
export function setStoredSessionId(id: string): void {
if (!id) return;
localStorage.setItem(SESSION_KEY, id);
}
export function clearStoredSessionId(): void {
localStorage.removeItem(SESSION_KEY);
}
export function getSessionIdFromSearch(search: string): string {
const params = new URLSearchParams(search);
return params.get("session") || "";
}
export function getSessionId(search: string): string {
return getSessionIdFromSearch(search) || getStoredSessionId();
}
export function buildSessionQuery(sessionId: string): string {
return sessionId ? `?session=${encodeURIComponent(sessionId)}` : "";
}