// app/services/session.server.ts import type { Session } from "@remix-run/node"; import { createCookieSessionStorage } from "@remix-run/node"; // export the whole sessionStorage object export let sessionStorage = createCookieSessionStorage({ cookie: { name: "_session", // use any name you want here sameSite: "lax", // this helps with CSRF path: "/", // remember to add this so the cookie will work in all routes httpOnly: true, // for security reasons, make this cookie http only secrets: ["s3cr3t"], // replace this with an actual secret secure: process.env.NODE_ENV === "production", // enable this in prod only }, }); export function getSession(request: Request): Promise { return sessionStorage.getSession(request.headers.get("Cookie")); } // you can also export the methods individually for your own usage export let { commitSession, destroySession } = sessionStorage;