From fc54b22d614887ae4050c2c540d3419073b61805 Mon Sep 17 00:00:00 2001 From: Tomofumi Chiba Date: Sun, 26 Nov 2023 00:06:30 +0900 Subject: [PATCH] fix --- server/auth.ts | 3 +++ server/db.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/auth.ts b/server/auth.ts index 6abaaab..7d73034 100644 --- a/server/auth.ts +++ b/server/auth.ts @@ -18,9 +18,12 @@ export async function getSession(req: Request) { export async function createSession(response: Response, userId: number) { const sessionId = await insertSession(userId); + const expires = new Date(); + expires.setMonth(expires.getMonth() + 1); setCookie(response.headers, { name: "session", value: sessionId, + expires, sameSite: "Lax", httpOnly: true, secure: true, diff --git a/server/db.ts b/server/db.ts index 375de2b..43e4c8f 100644 --- a/server/db.ts +++ b/server/db.ts @@ -550,6 +550,8 @@ function deleteExpiredSession(userId: number) { "updated_at", date.toISOString(), ).then(({ error }) => { - console.error(error); + if (error) { + console.error(error); + } }); }