mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-07 18:40:33 +00:00
store last visited org in cookie
This commit is contained in:
19
src/components/SetLastOrgCookie.tsx
Normal file
19
src/components/SetLastOrgCookie.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface SetLastOrgCookieProps {
|
||||
orgId: string;
|
||||
}
|
||||
|
||||
export default function SetLastOrgCookie({ orgId }: SetLastOrgCookieProps) {
|
||||
useEffect(() => {
|
||||
const isSecure =
|
||||
typeof window !== "undefined" &&
|
||||
window.location.protocol === "https:";
|
||||
|
||||
document.cookie = `pangolin-last-org=${orgId}; path=/; max-age=${60 * 60 * 24 * 30}; samesite=lax${isSecure ? "; secure" : ""}`;
|
||||
}, [orgId]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user