From dd9535b6583bab49939805038d6bcda9ba4bacb4 Mon Sep 17 00:00:00 2001 From: dooohun Date: Wed, 4 Dec 2024 18:03:57 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20=EC=84=B8=EC=85=98=20=EC=BF=A0?= =?UTF-8?q?=ED=82=A4=EB=A5=BC=20=EA=B8=B0=ED=95=9C=EC=9D=84=2030=EB=B6=84?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=84=A4=EC=A0=95=ED=95=9C=20persist=20?= =?UTF-8?q?=EC=BF=A0=ED=82=A4=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/client/src/pages/nickname/index.tsx | 2 +- packages/client/src/pages/quiz-list/ui/ClassItem.tsx | 2 +- packages/client/src/shared/hooks/useSocket.ts | 2 +- packages/client/src/shared/utils/cookie.ts | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/src/pages/nickname/index.tsx b/packages/client/src/pages/nickname/index.tsx index f21f2e83..a40ec541 100644 --- a/packages/client/src/pages/nickname/index.tsx +++ b/packages/client/src/pages/nickname/index.tsx @@ -31,7 +31,7 @@ export default function Nickname() { navigate(`/`); return; } - setCookie('sid', sid); + setCookie('sid', sid, 30); socket.emit('participant notice', { pinCode: pinCode }); navigate(`/quiz/wait/${pinCode}`); } catch (error) { diff --git a/packages/client/src/pages/quiz-list/ui/ClassItem.tsx b/packages/client/src/pages/quiz-list/ui/ClassItem.tsx index d8e4064b..0fa4bf94 100644 --- a/packages/client/src/pages/quiz-list/ui/ClassItem.tsx +++ b/packages/client/src/pages/quiz-list/ui/ClassItem.tsx @@ -38,7 +38,7 @@ export default function ClassItem({ index, quizList }: ClassItemProps) { socket.emit('master entry', { classId: id }); const sid = await waitForSocketEvent('session', socket); - setCookie('sid', sid); + setCookie('sid', sid, 30); const pinCode = await waitForSocketEvent('pincode', socket); diff --git a/packages/client/src/shared/hooks/useSocket.ts b/packages/client/src/shared/hooks/useSocket.ts index 06c50a5c..aaaf4c32 100644 --- a/packages/client/src/shared/hooks/useSocket.ts +++ b/packages/client/src/shared/hooks/useSocket.ts @@ -27,7 +27,7 @@ export const useSocket = () => { if (!sid) { socketRef.current.on('session', (sid: string) => { - setCookie('sid', sid); + setCookie('sid', sid, 30); }); } diff --git a/packages/client/src/shared/utils/cookie.ts b/packages/client/src/shared/utils/cookie.ts index cb92702d..d6bf1e91 100644 --- a/packages/client/src/shared/utils/cookie.ts +++ b/packages/client/src/shared/utils/cookie.ts @@ -8,12 +8,12 @@ export function getCookie(name: string) { return undefined; } -export function setCookie(name: string, val: any, day?: number) { +export function setCookie(name: string, val: any, minute?: number) { const date = new Date(); const value = val; - // day가 없는 경우 세션쿠키로 설정 - if (day) { - date.setTime(date.getTime() + day * 24 * 60 * 60 * 1000); + // minute가 없는 경우 세션쿠키로 설정 + if (minute) { + date.setTime(date.getTime() + minute * 60 * 1000); document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`; } else { document.cookie = `${name}=${value}; path=/`;