Save in a sqlite file the user session using next-session, similar to PHP. In this basic example you can see how to save primive(number,strings,) data and complex data (Person{name:string,age:string}) in a cookie session.
//sessions\get-session.js
import nextSession from "next-session";
import { expressSession, promisifyStore } from "next-session/lib/compat";
var SQLiteStore = require("connect-sqlite3")(expressSession);
export const getSession = nextSession({
name: "MYCUSTOMCOOKIE",
store: promisifyStore(
new SQLiteStore({ dir: "./tmp/", table: "myCustomSessions" })
),
});- Clone the repository
- npm install
- npm run dev
- visit http://localhost:3000/