You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
678 B
26 lines
678 B
import type { H3Event } from "h3";
|
|
import {
|
|
SESSION_COOKIE_NAME,
|
|
SESSION_COOKIE_PATH,
|
|
SESSION_MAX_AGE_SECONDS,
|
|
} from "#server/constants/auth";
|
|
|
|
export function getSessionId(event: H3Event) {
|
|
return getCookie(event, SESSION_COOKIE_NAME);
|
|
}
|
|
|
|
export function clearSessionCookie(event: H3Event) {
|
|
deleteCookie(event, SESSION_COOKIE_NAME, {
|
|
path: SESSION_COOKIE_PATH,
|
|
});
|
|
}
|
|
|
|
export function setSessionCookie(event: H3Event, sessionId: string) {
|
|
setCookie(event, SESSION_COOKIE_NAME, sessionId, {
|
|
httpOnly: true,
|
|
sameSite: "lax",
|
|
secure: process.env.NODE_ENV === "production",
|
|
path: SESSION_COOKIE_PATH,
|
|
maxAge: SESSION_MAX_AGE_SECONDS,
|
|
});
|
|
}
|
|
|