Skip to content

HastaCs/next_session_sqlite

Repository files navigation

Saving session in nextjs

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.

next-session

Important code

//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" })
  ),
  
});

Using the demo


  1. Clone the repository
  2. npm install
  3. npm run dev
  4. visit http://localhost:3000/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors