From ea0236d731743439296b43be176171429119fe03 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Sat, 17 Aug 2024 04:51:13 +0530 Subject: [PATCH] feat(frontend): make redirect cookies long lived --- apps/frontend/app/lib/hooks.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/frontend/app/lib/hooks.ts b/apps/frontend/app/lib/hooks.ts index 2bae31fde0..35240c27a6 100644 --- a/apps/frontend/app/lib/hooks.ts +++ b/apps/frontend/app/lib/hooks.ts @@ -14,6 +14,7 @@ import { $path } from "remix-routes"; import { useInterval } from "usehooks-ts"; import { CurrentWorkoutKey, + dayjsLib, getMetadataDetailsQuery, getStringAsciiValue, getUserMetadataDetailsQuery, @@ -41,13 +42,16 @@ export const useFallbackImageUrl = (text = "No Image") => { export const useAppSearchParam = (cookieKey: string) => { const [searchParams, setSearchParams] = useSearchParams(); + const coreDetails = useCoreDetails(); const updateCookieP = (key: string, value?: string | null) => { const cookieValue = Cookies.get(cookieKey); const cookieSearchParams = new URLSearchParams(cookieValue); if (!value) cookieSearchParams.delete(key); else cookieSearchParams.set(key, value); - Cookies.set(cookieKey, cookieSearchParams.toString()); + Cookies.set(cookieKey, cookieSearchParams.toString(), { + expires: dayjsLib().add(coreDetails.tokenValidForDays, "day").toDate(), + }); }; const delP = (key: string) => {