blob: 0ad9a5d64a663cbcd60e01672fb116d7db36fad9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
export async function clearOdooSession(baseUrl: string) {
try {
if (baseUrl) {
await fetch(`${baseUrl}/web/session/destroy`, {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: "{}",
});
}
} catch { }
// 2) hapus cookie session_id di browser
try {
const del = (name: string, domain?: string) => {
const d = domain ? `; domain=${domain}` : "";
document.cookie = `${name}=; Max-Age=0; Path=/${d}`;
document.cookie = `${name}=; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/${d}`;
};
const host = window.location.hostname.replace(/^www\./, "");
const parts = host.split(".");
const parent = parts.length >= 2 ? `.${parts.slice(-2).join(".")}` : undefined;
[undefined, host, parent].forEach(dom => del("session_id", dom));
} catch { }
}
|